Skip to content

Commit

Permalink
Auto merge of #3912 - Turbo87:handlebars, r=locks
Browse files Browse the repository at this point in the history
Update `handlebars` crate to v4.1.3

see https://github.com/sunng87/handlebars-rust/blob/master/CHANGELOG.md

~It looks like none of the breaking changes in the v4 release are relevant to us.~

Update: I was wrong, sunng87/handlebars-rust#404 does affect us. I've added another commit which removes the now problematic handlebars whitespace control characters.
  • Loading branch information
bors committed Sep 13, 2021
2 parents ee04493 + 030a8fb commit ed87d18
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
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;

0 comments on commit ed87d18

Please sign in to comment.