Skip to content

Commit 0565e19

Browse files
committed
Auto merge of #1996 - bruceadams:no-trigger-during-import, r=smarnach
Disable database triggers during import - This allows `updated_at` field values to be loaded during import. Before this change, `updated_at` was set to when the import ran, overwriting the values being loaded. - Also, the import completes in about one fifth the time (on my slow MacBook Air).
2 parents 97ecbf3 + 7415074 commit 0565e19

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/tasks/dump_db/dump-import.sql.hbs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
BEGIN;
2+
-- Disable triggers on each table.
3+
{{~#each tables}}
4+
ALTER TABLE "{{this.name}}" DISABLE TRIGGER ALL;
5+
{{~/each}}
6+
27
-- Set defaults for non-nullable columns not included in the dump.
38
{{~#each tables as |table|}}
49
{{~#each column_defaults}}
@@ -21,5 +26,10 @@ BEGIN;
2126
{{~#each column_defaults}}
2227
ALTER TABLE "{{table.name}}" ALTER COLUMN "{{@key}}" DROP DEFAULT;
2328
{{~/each}}
29+
{{~/each}}
30+
31+
-- Reenable triggers on each table.
32+
{{~#each tables}}
33+
ALTER TABLE "{{this.name}}" ENABLE TRIGGER ALL;
2434
{{~/each}}
2535
COMMIT;

0 commit comments

Comments
 (0)