Skip to content

Commit

Permalink
fix: migration zero should be properly skipped if migrations are alre…
Browse files Browse the repository at this point in the history
…ady in bot
  • Loading branch information
sogehige committed Oct 29, 2023
1 parent 5651cc3 commit 1e9f35a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/database/migration/mysql/1000000000001-initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down
4 changes: 3 additions & 1 deletion src/database/migration/postgres/1000000000001-initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"))`);
Expand Down
4 changes: 3 additions & 1 deletion src/database/migration/sqlite/1000000000001-initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)`);
Expand Down

0 comments on commit 1e9f35a

Please sign in to comment.