Skip to content
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

Update handlebars crate to v4.1.3 #3912

Merged
merged 2 commits into from Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -59,7 +59,7 @@ flate2 = "1.0"
futures-channel = { version = "0.3.1", default-features = false }
futures-util = "0.3"
git2 = "0.13.0"
handlebars = "3.0.1"
handlebars = "4.1.3"
hex = "0.4"
htmlescape = "0.3.1"
http = "0.2"
Expand Down
10 changes: 5 additions & 5 deletions src/tasks/dump_db/dump-export.sql.hbs
@@ -1,9 +1,9 @@
BEGIN ISOLATION LEVEL REPEATABLE READ, READ ONLY;
{{~#each tables}}
{{~#if this.filter}}
{{#each tables}}
{{#if this.filter}}
\copy (SELECT {{this.columns}} FROM "{{this.name}}" WHERE {{this.filter}}) TO 'data/{{this.name}}.csv' WITH CSV HEADER
{{~else}}
{{else}}
\copy "{{this.name}}" ({{this.columns}}) TO 'data/{{this.name}}.csv' WITH CSV HEADER
{{~/if}}
{{~/each}}
{{/if}}
{{/each}}
COMMIT;
32 changes: 16 additions & 16 deletions src/tasks/dump_db/dump-import.sql.hbs
@@ -1,38 +1,38 @@
BEGIN;
-- Disable triggers on each table.
{{~#each tables}}
{{#each tables}}
ALTER TABLE "{{this.name}}" DISABLE TRIGGER ALL;
{{~/each}}
{{/each}}

-- Set defaults for non-nullable columns not included in the dump.
{{~#each tables as |table|}}
{{~#each column_defaults}}
{{#each tables as |table|}}
{{#each column_defaults}}
ALTER TABLE "{{table.name}}" ALTER COLUMN "{{@key}}" SET DEFAULT {{this}};
{{~/each}}
{{~/each}}
{{/each}}
{{/each}}

-- Truncate all tables.
{{~#each tables}}
{{#each tables}}
TRUNCATE "{{this.name}}" RESTART IDENTITY CASCADE;
{{~/each}}
{{/each}}

-- Enable this trigger so that `crates.textsearchable_index_col` can be excluded from the export
ALTER TABLE "crates" ENABLE TRIGGER "trigger_crates_tsvector_update";

-- Import the CSV data.
{{~#each tables}}
{{#each tables}}
\copy "{{this.name}}" ({{this.columns}}) FROM 'data/{{this.name}}.csv' WITH CSV HEADER
{{~/each}}
{{/each}}

-- Drop the defaults again.
{{~#each tables as |table|}}
{{~#each column_defaults}}
{{#each tables as |table|}}
{{#each column_defaults}}
ALTER TABLE "{{table.name}}" ALTER COLUMN "{{@key}}" DROP DEFAULT;
{{~/each}}
{{~/each}}
{{/each}}
{{/each}}

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