From 08a2f60f72f30246dd5801289afcd63d4339ad2e Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Thu, 8 Dec 2022 21:58:58 +0100 Subject: [PATCH] chore: add migration for v0.3.3 --- .../20221208191607_v0_3_3/migration.sql | 17 +++++++++++++++++ backend/prisma/seed/config.seed.ts | 10 ++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 backend/prisma/migrations/20221208191607_v0_3_3/migration.sql diff --git a/backend/prisma/migrations/20221208191607_v0_3_3/migration.sql b/backend/prisma/migrations/20221208191607_v0_3_3/migration.sql new file mode 100644 index 0000000..5740bf8 --- /dev/null +++ b/backend/prisma/migrations/20221208191607_v0_3_3/migration.sql @@ -0,0 +1,17 @@ +-- RedefineTables +PRAGMA foreign_keys=OFF; +CREATE TABLE "new_Config" ( + "updatedAt" DATETIME NOT NULL, + "key" TEXT NOT NULL PRIMARY KEY, + "type" TEXT NOT NULL, + "value" TEXT NOT NULL, + "description" TEXT NOT NULL, + "obscured" BOOLEAN NOT NULL DEFAULT false, + "secret" BOOLEAN NOT NULL DEFAULT true, + "locked" BOOLEAN NOT NULL DEFAULT false +); +INSERT INTO "new_Config" ("description", "key", "locked", "secret", "type", "updatedAt", "value") SELECT "description", "key", "locked", "secret", "type", "updatedAt", "value" FROM "Config"; +DROP TABLE "Config"; +ALTER TABLE "new_Config" RENAME TO "Config"; +PRAGMA foreign_key_check; +PRAGMA foreign_keys=ON; diff --git a/backend/prisma/seed/config.seed.ts b/backend/prisma/seed/config.seed.ts index 2b08312..bf856d3 100644 --- a/backend/prisma/seed/config.seed.ts +++ b/backend/prisma/seed/config.seed.ts @@ -124,16 +124,18 @@ async function main() { // Update the config variable if the metadata changed } else if ( JSON.stringify({ + ...configVariable, key: configVariableFromDatabase.key, value: configVariableFromDatabase.value, - ...configVariable, }) != JSON.stringify(configVariableFromDatabase) ) { await prisma.config.update({ where: { key: configVariableFromDatabase.key }, - data: configVariables.find( - (v) => v.key == configVariableFromDatabase.key - ), + data: { + ...configVariable, + key: configVariableFromDatabase.key, + value: configVariableFromDatabase.value, + }, }); } }