Skip to content

Disable database triggers during import #1996

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

Merged
merged 2 commits into from
Dec 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/tasks/dump_db/dump-import.sql.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
BEGIN;
-- Disable triggers on each table.
{{~#each tables}}
ALTER TABLE "{{this.name}}" DISABLE TRIGGER ALL;
{{~/each}}

-- Set defaults for non-nullable columns not included in the dump.
{{~#each tables as |table|}}
{{~#each column_defaults}}
Expand All @@ -21,5 +26,10 @@ BEGIN;
{{~#each column_defaults}}
ALTER TABLE "{{table.name}}" ALTER COLUMN "{{@key}}" DROP DEFAULT;
{{~/each}}
{{~/each}}

-- Reenable triggers on each table.
{{~#each tables}}
ALTER TABLE "{{this.name}}" ENABLE TRIGGER ALL;
{{~/each}}
COMMIT;