Skip to content

Commit d8b8235

Browse files
committed
Move db_dump filtering logic into main read-only transaction
1 parent 7d084d3 commit d8b8235

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
BEGIN;
1+
BEGIN ISOLATION LEVEL SERIALIZABLE READ ONLY DEFERRABLE;
22
{{~#each tables}}
33
{{~#if this.filter}}
4-
CREATE TEMPORARY VIEW "dump_db_{{this.name}}" AS (
4+
\copy (
55
SELECT {{this.columns}}
66
FROM "{{this.name}}"
77
WHERE {{this.filter}}
8-
);
9-
{{~/if}}
10-
{{~/each}}
11-
COMMIT;
12-
13-
BEGIN ISOLATION LEVEL SERIALIZABLE READ ONLY DEFERRABLE;
14-
{{~#each tables}}
15-
{{~#if this.filter}}
16-
\copy (SELECT * FROM "dump_db_{{this.name}}") TO 'data/{{this.name}}.csv' WITH CSV HEADER
8+
) TO 'data/{{this.name}}.csv' WITH CSV HEADER
179
{{~else}}
1810
\copy "{{this.name}}" ({{this.columns}}) TO 'data/{{this.name}}.csv' WITH CSV HEADER
1911
{{~/if}}

0 commit comments

Comments
 (0)