From b91057b70cbb7bf0ca13ed1f2fd5fa5ec71c39f3 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Fri, 10 Sep 2021 17:29:34 +0200 Subject: [PATCH 1/2] Update `handlebars` crate to v4.1.3 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e99ce2fd82..3cda25be28 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1031,9 +1031,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "3.5.5" +version = "4.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4498fc115fa7d34de968184e473529abb40eeb6be8bc5f7faba3d08c316cb3e3" +checksum = "66b09e2322d20d14bc2572401ce7c1d60b4748580a76c230ed9c1f8938f0c833" dependencies = [ "log", "pest", diff --git a/Cargo.toml b/Cargo.toml index e04545e72d..04cfa63216 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" From 030a8fb3930f4ba93b1b42bb4ee586a3464a85f3 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Fri, 10 Sep 2021 18:20:14 +0200 Subject: [PATCH 2/2] dump_db: Remove handlebars whitespace control characters --- src/tasks/dump_db/dump-export.sql.hbs | 10 ++++----- src/tasks/dump_db/dump-import.sql.hbs | 32 +++++++++++++-------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/tasks/dump_db/dump-export.sql.hbs b/src/tasks/dump_db/dump-export.sql.hbs index 99952df693..2b7c4765fa 100644 --- a/src/tasks/dump_db/dump-export.sql.hbs +++ b/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; diff --git a/src/tasks/dump_db/dump-import.sql.hbs b/src/tasks/dump_db/dump-import.sql.hbs index f9c5ac5dd4..4f9147772a 100644 --- a/src/tasks/dump_db/dump-import.sql.hbs +++ b/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;