-
-
Notifications
You must be signed in to change notification settings - Fork 55
Dropdb should be forced to close any active connections and not fail #213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| def wipe_development_database | ||
| Kernel.system( | ||
| "dropdb --if-exists #{development_db} && createdb #{development_db}", | ||
| "dropdb --if-exists #{development_db} --force && createdb #{development_db}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [85/80]
…ort specific backup IDs. Added logging for restoration processes and updated tests to verify new behavior.
| log_restore_info | ||
| reset_remote_database | ||
| # Filter out --backup-id from additional_args as it's handled separately | ||
| filtered_args = additional_args.gsub(/--backup-id\s+\S+/, '').strip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
| def restore_from_local_temp_backup | ||
| puts "Restoring backup to #{development_db}..." | ||
| # Filter out --backup-id from additional_args as it's not needed for pg_restore | ||
| filtered_args = additional_args.gsub(/--backup-id\s+\S+/, '').strip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style/StringLiterals: Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.
|
|
||
| def restore_from_local_temp_backup | ||
| puts "Restoring backup to #{development_db}..." | ||
| # Filter out --backup-id from additional_args as it's not needed for pg_restore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [85/80]
| else | ||
| puts "Downloading latest backup from #{from}..." | ||
| Kernel.system( | ||
| "curl -o tmp/latest.backup \"$(heroku pg:backups:url --remote #{from})\"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [84/80]
| if backup_id | ||
| puts "Downloading backup #{backup_id} from #{from}..." | ||
| Kernel.system( | ||
| "curl -o tmp/#{backup_id}.backup \"$(heroku pg:backups:url #{backup_id} --remote #{from})\"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [103/80]
| # Filter out special flags that are handled separately | ||
| filtered_args = arguments.drop(1) - ["--force", "--parallelize"] | ||
| # Filter out --backup-id as it's handled separately by the Backup class | ||
| filtered_args = filtered_args.reject { |arg| arg.start_with?("--backup-id") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [83/80]
| ).restore | ||
| } | ||
| backup_args[:backup_id] = backup_id? if backup_id? | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/TrailingWhitespace: Trailing whitespace detected.
| "--dbname #{default_db_name} --jobs=#{cores} " | ||
| end | ||
|
|
||
| def specific_backup_id_restore_from_local_temp_backup_command(cores: number_of_processes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [91/80]
| end | ||
|
|
||
| def specific_backup_id_download_command | ||
| 'curl -o tmp/b001.backup "$(heroku pg:backups:url b001 --remote production)"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [81/80]
| with(create_heroku_ext_schema_command) | ||
| expect(Kernel). | ||
| to have_received(:system). | ||
| with(specific_backup_id_restore_from_local_temp_backup_command(cores: 1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Metrics/LineLength: Line is too long. [81/80]
| else | ||
| puts "Downloading latest backup from #{from}..." | ||
| Kernel.system( | ||
| "curl -o tmp/latest.backup \"$(heroku pg:backups:url --remote #{from})\"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use the same curl statement in both places since a nil backup_id would be an empty string here? This would avoid having two pieces of interpolated string arguments to maintain going forward where we could have one.
|
|
||
| alias :parallelize? :parallelize | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trim these down, please.
| if backup_id_index && backup_id_index + 1 < arguments.length | ||
| arguments[backup_id_index + 1] | ||
| end | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The predicate method should return a boolean result. Given that you're using the ID returned here I think the ? should be dropped from the method name.
This pull request includes a small change to the
restore_to_developmentmethod inlib/parity/backup.rb. The change ensures that thedropdbcommand is executed with the--forceflag to enforce the removal of the development database even if there are active connections.