Skip to content

Commit 99ad263

Browse files
committed
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).
1 parent 1fc6bfa commit 99ad263

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
BEGIN;
2+
-- Disable triggers on each table.
3+
{{~#each tables}}
4+
ALTER TABLE "{{this.name}}" DISABLE TRIGGER ALL;
5+
{{~/each}}
6+
COMMIT;
7+
18
BEGIN;
29
-- Set defaults for non-nullable columns not included in the dump.
310
{{~#each tables as |table|}}
@@ -23,3 +30,10 @@ BEGIN;
2330
{{~/each}}
2431
{{~/each}}
2532
COMMIT;
33+
34+
BEGIN;
35+
-- Reenable triggers on each table.
36+
{{~#each tables}}
37+
ALTER TABLE "{{this.name}}" ENABLE TRIGGER ALL;
38+
{{~/each}}
39+
COMMIT;

0 commit comments

Comments
 (0)