Skip to content

Commit

Permalink
add --if-exists --single-transaction --exit-on-error
Browse files Browse the repository at this point in the history
  • Loading branch information
erplsf committed May 16, 2024
1 parent c7c6325 commit c204628
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pg_migration_tool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def generate_pg_dump_and_restore_cmd(self, event: Select.Changed)-> str:
db = config["dbs"][event.value]
dump_path = self.construct_path_to_dump(db)
pg_dump_cmd = f'PGPASSWORD="{db['source']['db_password']}" pg_dump -h {db['source']['db_connection_host']} -U {db['source']['db_username']} -d {db['source']['db_database_name']} --create --clean --encoding utf8 --format directory --jobs 16 -Z 0 -v --file={dump_path}'
pg_restore_cmd = f'PGPASSWORD="{db['target']['db_password']}" pg_restore -h {db['target']['db_connection_host']} -U {db['target']['db_username']} -d {db['target']['db_database_name']} --clean -vv {dump_path}'
pg_restore_cmd = f'PGPASSWORD="{db['target']['db_password']}" pg_restore -h {db['target']['db_connection_host']} -U {db['target']['db_username']} -d {db['target']['db_database_name']} --clean --if-exists --single-transaction --exit-on-error --format directory -vv {dump_path}'

cmd = " && /\n ".join([pg_dump_cmd, pg_restore_cmd])
self.query_one(Log).write_line("The following migration commands will be executed:\n" + cmd)
Expand Down

0 comments on commit c204628

Please sign in to comment.