From 1e9f35a8d7687d253cc50d5e01d01cd98a52aec9 Mon Sep 17 00:00:00 2001 From: Michal Orlik Date: Sun, 29 Oct 2023 19:11:54 +0100 Subject: [PATCH] fix: migration zero should be properly skipped if migrations are already in bot --- src/database/migration/mysql/1000000000001-initialize.ts | 1 + src/database/migration/postgres/1000000000001-initialize.ts | 4 +++- src/database/migration/sqlite/1000000000001-initialize.ts | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/database/migration/mysql/1000000000001-initialize.ts b/src/database/migration/mysql/1000000000001-initialize.ts index 16e02f9046fd..cf9f8bba805a 100644 --- a/src/database/migration/mysql/1000000000001-initialize.ts +++ b/src/database/migration/mysql/1000000000001-initialize.ts @@ -8,6 +8,7 @@ export class initialize1000000000001 implements MigrationInterface { const migrations = await queryRunner.query(`SELECT * FROM \`migrations\``); if (migrations.length > 0) { console.log('Skipping migration zero, migrations are already in bot'); + return; } await queryRunner.query(`CREATE TABLE \`alert\` (\`id\` varchar(36) NOT NULL, \`updatedAt\` varchar(30) NULL, \`name\` varchar(255) NOT NULL, \`alertDelayInMs\` int NOT NULL, \`profanityFilterType\` varchar(255) NOT NULL, \`loadStandardProfanityList\` json NOT NULL, \`parry\` json NOT NULL, \`tts\` json NULL, \`fontMessage\` json NOT NULL, \`font\` json NOT NULL, \`customProfanityList\` varchar(255) NOT NULL, \`items\` json NOT NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); await queryRunner.query(`CREATE TABLE \`alias\` (\`id\` varchar(36) NOT NULL, \`alias\` varchar(255) NOT NULL, \`command\` text NOT NULL, \`enabled\` tinyint NOT NULL, \`visible\` tinyint NOT NULL, \`permission\` varchar(255) NULL, \`group\` varchar(255) NULL, INDEX \`IDX_6a8a594f0a5546f8082b0c405c\` (\`alias\`), PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); diff --git a/src/database/migration/postgres/1000000000001-initialize.ts b/src/database/migration/postgres/1000000000001-initialize.ts index d6eedd21f049..a62c48f73e06 100644 --- a/src/database/migration/postgres/1000000000001-initialize.ts +++ b/src/database/migration/postgres/1000000000001-initialize.ts @@ -8,7 +8,9 @@ export class initialize1000000000001 implements MigrationInterface { const migrations = await queryRunner.query(`SELECT * FROM "migrations"`); if (migrations.length > 0) { console.log('Skipping migration zero, migrations are already in bot'); - } await queryRunner.query(`CREATE TABLE "alert" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "updatedAt" character varying(30), "name" character varying NOT NULL, "alertDelayInMs" integer NOT NULL, "profanityFilterType" character varying NOT NULL, "loadStandardProfanityList" json NOT NULL, "parry" json NOT NULL, "tts" json, "fontMessage" json NOT NULL, "font" json NOT NULL, "customProfanityList" character varying NOT NULL, "items" json NOT NULL, CONSTRAINT "PK_ad91cad659a3536465d564a4b2f" PRIMARY KEY ("id"))`); + return; + } + await queryRunner.query(`CREATE TABLE "alert" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "updatedAt" character varying(30), "name" character varying NOT NULL, "alertDelayInMs" integer NOT NULL, "profanityFilterType" character varying NOT NULL, "loadStandardProfanityList" json NOT NULL, "parry" json NOT NULL, "tts" json, "fontMessage" json NOT NULL, "font" json NOT NULL, "customProfanityList" character varying NOT NULL, "items" json NOT NULL, CONSTRAINT "PK_ad91cad659a3536465d564a4b2f" PRIMARY KEY ("id"))`); await queryRunner.query(`CREATE TABLE "alias" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "alias" character varying NOT NULL, "command" text NOT NULL, "enabled" boolean NOT NULL, "visible" boolean NOT NULL, "permission" character varying, "group" character varying, CONSTRAINT "PK_b1848d04b41d10a5712fc2e673c" PRIMARY KEY ("id"))`); await queryRunner.query(`CREATE INDEX "IDX_6a8a594f0a5546f8082b0c405c" ON "alias" ("alias") `); await queryRunner.query(`CREATE TABLE "alias_group" ("name" character varying NOT NULL, "options" text NOT NULL, CONSTRAINT "PK_2d40a2a41c8eb8d436b6ce1387c" PRIMARY KEY ("name"))`); diff --git a/src/database/migration/sqlite/1000000000001-initialize.ts b/src/database/migration/sqlite/1000000000001-initialize.ts index 1403e8077fb6..df4dba4e50a6 100644 --- a/src/database/migration/sqlite/1000000000001-initialize.ts +++ b/src/database/migration/sqlite/1000000000001-initialize.ts @@ -8,7 +8,9 @@ export class initialize1000000000001 implements MigrationInterface { const migrations = await queryRunner.query(`SELECT * FROM "migrations"`); if (migrations.length > 0) { console.log('Skipping migration zero, migrations are already in bot'); - } await queryRunner.query(`CREATE TABLE "alert" ("id" varchar PRIMARY KEY NOT NULL, "updatedAt" varchar(30), "name" varchar NOT NULL, "alertDelayInMs" integer NOT NULL, "profanityFilterType" varchar NOT NULL, "loadStandardProfanityList" text NOT NULL, "parry" text NOT NULL, "tts" text, "fontMessage" text NOT NULL, "font" text NOT NULL, "customProfanityList" varchar NOT NULL, "items" text NOT NULL)`); + return; + } + await queryRunner.query(`CREATE TABLE "alert" ("id" varchar PRIMARY KEY NOT NULL, "updatedAt" varchar(30), "name" varchar NOT NULL, "alertDelayInMs" integer NOT NULL, "profanityFilterType" varchar NOT NULL, "loadStandardProfanityList" text NOT NULL, "parry" text NOT NULL, "tts" text, "fontMessage" text NOT NULL, "font" text NOT NULL, "customProfanityList" varchar NOT NULL, "items" text NOT NULL)`); await queryRunner.query(`CREATE TABLE "alias" ("id" varchar PRIMARY KEY NOT NULL, "alias" varchar NOT NULL, "command" text NOT NULL, "enabled" boolean NOT NULL, "visible" boolean NOT NULL, "permission" varchar, "group" varchar)`); await queryRunner.query(`CREATE INDEX "IDX_6a8a594f0a5546f8082b0c405c" ON "alias" ("alias") `); await queryRunner.query(`CREATE TABLE "alias_group" ("name" varchar PRIMARY KEY NOT NULL, "options" text NOT NULL)`);