Exit on error when restoring all PostgreSQL databases

"--set ON_ERROR_STOP=on" is equivalent to "--exit-on-error" in
pg_restore.
This commit is contained in:
Jakub Jirutka 2023-04-14 16:27:45 +02:00
parent 195024e505
commit dfccc1b94a
2 changed files with 2 additions and 2 deletions

View file

@ -223,7 +223,7 @@ def restore_database_dump(database_config, log_prefix, location_config, dry_run,
+ ( + (
('--if-exists', '--exit-on-error', '--clean', '--dbname', database['name']) ('--if-exists', '--exit-on-error', '--clean', '--dbname', database['name'])
if not all_databases if not all_databases
else ('--no-psqlrc',) else ('--no-psqlrc', '--set', 'ON_ERROR_STOP=on')
) )
+ (('--host', database['hostname']) if 'hostname' in database else ()) + (('--host', database['hostname']) if 'hostname' in database else ())
+ (('--port', str(database['port'])) if 'port' in database else ()) + (('--port', str(database['port'])) if 'port' in database else ())

View file

@ -607,7 +607,7 @@ def test_restore_database_dump_runs_psql_for_all_database_dump():
flexmock(module).should_receive('make_dump_path') flexmock(module).should_receive('make_dump_path')
flexmock(module.dump).should_receive('make_database_dump_filename') flexmock(module.dump).should_receive('make_database_dump_filename')
flexmock(module).should_receive('execute_command_with_processes').with_args( flexmock(module).should_receive('execute_command_with_processes').with_args(
('psql', '--no-password', '--no-psqlrc'), ('psql', '--no-password', '--no-psqlrc', '--set', 'ON_ERROR_STOP=on'),
processes=[extract_process], processes=[extract_process],
output_log_level=logging.DEBUG, output_log_level=logging.DEBUG,
input_file=extract_process.stdout, input_file=extract_process.stdout,