Skip to content
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

Modify restoreDbFromSource to drop all target tables before restore #5642

Conversation

Mwindo
Copy link
Contributor

@Mwindo Mwindo commented Dec 10, 2024

Our current implementation of restoreDbFromSource only drops and re-creates tables in our target db that exist in our pg_dump. Instead, we want a clean slate in our target db.

We could drop and re-create the target database or drop and re-create the target schema, but both of these involve dealing with stricter permissions. Instead, the approach in this PR is to query for all of the tables from the target schema and drop them.

@@ -215,8 +215,61 @@ async function restoreFromBackup({
});
const targetPassword = await targetSigner.getAuthToken();

// pg_restore only drops tables in the dump, so we drop all tables before pg_restore.
Copy link
Contributor Author

@Mwindo Mwindo Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script file is getting long/clumsy. I will see if there are easy ways to simplify in the near future.

@Mwindo Mwindo marked this pull request as ready for review December 20, 2024 17:14
@jimlerza jimlerza merged commit 32a21e5 into ustaxcourt:staging Dec 23, 2024
15 checks passed
@jimlerza jimlerza deleted the restoreDbFromSource-drop-all-target-tables-before-restore branch December 23, 2024 20:29
@jimlerza jimlerza mentioned this pull request Jan 3, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants