File tree 2 files changed +21
-21
lines changed
2 files changed +21
-21
lines changed Original file line number Diff line number Diff line change 1
1
BEGIN ISOLATION LEVEL REPEATABLE READ, READ ONLY;
2
- {{ ~ #each tables }}
3
- {{ ~ #if this.filter }}
2
+ {{ #each tables }}
3
+ {{ #if this.filter }}
4
4
\copy (SELECT {{ this.columns }} FROM "{{ this.name }} " WHERE {{ this.filter }} ) TO 'data/{{ this.name }} .csv' WITH CSV HEADER
5
- {{ ~ else}}
5
+ {{ else }}
6
6
\copy "{{ this.name }} " ({{ this.columns }} ) TO 'data/{{ this.name }} .csv' WITH CSV HEADER
7
- {{ ~ /if}}
8
- {{ ~ /each}}
7
+ {{ /if }}
8
+ {{ /each }}
9
9
COMMIT;
Original file line number Diff line number Diff line change 1
1
BEGIN;
2
2
-- Disable triggers on each table.
3
- {{ ~ #each tables }}
3
+ {{ #each tables }}
4
4
ALTER TABLE "{{ this.name }} " DISABLE TRIGGER ALL;
5
- {{ ~ /each}}
5
+ {{ /each }}
6
6
7
7
-- Set defaults for non-nullable columns not included in the dump.
8
- {{ ~ #each tables as |table |}}
9
- {{ ~ #each column_defaults }}
8
+ {{ #each tables as |table |}}
9
+ {{ #each column_defaults }}
10
10
ALTER TABLE "{{ table.name }} " ALTER COLUMN "{{ @key }} " SET DEFAULT {{ this }} ;
11
- {{ ~ /each}}
12
- {{ ~ /each}}
11
+ {{ /each }}
12
+ {{ /each }}
13
13
14
14
-- Truncate all tables.
15
- {{ ~ #each tables }}
15
+ {{ #each tables }}
16
16
TRUNCATE "{{ this.name }} " RESTART IDENTITY CASCADE;
17
- {{ ~ /each}}
17
+ {{ /each }}
18
18
19
19
-- Enable this trigger so that `crates.textsearchable_index_col` can be excluded from the export
20
20
ALTER TABLE "crates" ENABLE TRIGGER "trigger_crates_tsvector_update";
21
21
22
22
-- Import the CSV data.
23
- {{ ~ #each tables }}
23
+ {{ #each tables }}
24
24
\copy "{{ this.name }} " ({{ this.columns }} ) FROM 'data/{{ this.name }} .csv' WITH CSV HEADER
25
- {{ ~ /each}}
25
+ {{ /each }}
26
26
27
27
-- Drop the defaults again.
28
- {{ ~ #each tables as |table |}}
29
- {{ ~ #each column_defaults }}
28
+ {{ #each tables as |table |}}
29
+ {{ #each column_defaults }}
30
30
ALTER TABLE "{{ table.name }} " ALTER COLUMN "{{ @key }} " DROP DEFAULT;
31
- {{ ~ /each}}
32
- {{ ~ /each}}
31
+ {{ /each }}
32
+ {{ /each }}
33
33
34
34
-- Reenable triggers on each table.
35
- {{ ~ #each tables }}
35
+ {{ #each tables }}
36
36
ALTER TABLE "{{ this.name }} " ENABLE TRIGGER ALL;
37
- {{ ~ /each}}
37
+ {{ /each }}
38
38
COMMIT;
You can’t perform that action at this time.
0 commit comments