Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(quotes): set id to be integer (#3689)
* fix(quotes): set id to be integer * fix migration * fix integer range * fix integer 2
- Loading branch information
Showing
9 changed files
with
77 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/bot/database/migration/mysql/1588973421498-quotesIdToInt.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {MigrationInterface, QueryRunner} from 'typeorm'; | ||
|
||
export class quotesIdToInt1588973421498 implements MigrationInterface { | ||
name = 'quotesIdToInt1588973421498'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query('ALTER TABLE `quotes` DROP PRIMARY KEY', undefined); | ||
await queryRunner.query('ALTER TABLE `quotes` DROP COLUMN `id`', undefined); | ||
await queryRunner.query('ALTER TABLE `quotes` ADD `id` int NOT NULL PRIMARY KEY AUTO_INCREMENT', undefined); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query('ALTER TABLE `quotes` DROP COLUMN `id`', undefined); | ||
await queryRunner.query('ALTER TABLE `quotes` ADD `id` varchar(36) NOT NULL', undefined); | ||
await queryRunner.query('ALTER TABLE `quotes` ADD PRIMARY KEY (`id`)', undefined); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/bot/database/migration/postgres/1588971215782-quotesIdToInt.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import {MigrationInterface, QueryRunner} from 'typeorm'; | ||
|
||
export class quotesIdToInt1588971215782 implements MigrationInterface { | ||
name = 'quotesIdToInt1588971215782'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "quotes" DROP CONSTRAINT "PK_99a0e8bcbcd8719d3a41f23c263"`, undefined); | ||
await queryRunner.query(`ALTER TABLE "quotes" DROP COLUMN "id"`, undefined); | ||
await queryRunner.query(`ALTER TABLE "quotes" ADD "id" SERIAL NOT NULL`, undefined); | ||
await queryRunner.query(`ALTER TABLE "quotes" ADD CONSTRAINT "PK_99a0e8bcbcd8719d3a41f23c263" PRIMARY KEY ("id")`, undefined); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "quotes" DROP CONSTRAINT "PK_99a0e8bcbcd8719d3a41f23c263"`, undefined); | ||
await queryRunner.query(`ALTER TABLE "quotes" DROP COLUMN "id"`, undefined); | ||
await queryRunner.query(`ALTER TABLE "quotes" ADD "id" uuid NOT NULL DEFAULT uuid_generate_v4()`, undefined); | ||
await queryRunner.query(`ALTER TABLE "quotes" ADD CONSTRAINT "PK_99a0e8bcbcd8719d3a41f23c263" PRIMARY KEY ("id")`, undefined); | ||
} | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
src/bot/database/migration/sqlite/1588962416420-quotesIdToInt.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {MigrationInterface, QueryRunner} from 'typeorm'; | ||
|
||
export class quotesIdToInt1588962416420 implements MigrationInterface { | ||
name = 'quotesIdToInt1588962416420'; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`CREATE TABLE "temporary_quotes" ("id" varchar PRIMARY KEY NOT NULL, "tags" text NOT NULL, "quote" varchar NOT NULL, "quotedBy" integer NOT NULL, "createdAt" bigint NOT NULL)`, undefined); | ||
await queryRunner.query(`INSERT INTO "temporary_quotes"("id", "tags", "quote", "quotedBy", "createdAt") SELECT "id", "tags", "quote", "quotedBy", "createdAt" FROM "quotes"`, undefined); | ||
await queryRunner.query(`DROP TABLE "quotes"`, undefined); | ||
await queryRunner.query(`ALTER TABLE "temporary_quotes" RENAME TO "quotes"`, undefined); | ||
await queryRunner.query(`CREATE TABLE "temporary_quotes" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "tags" text NOT NULL, "quote" varchar NOT NULL, "quotedBy" integer NOT NULL, "createdAt" bigint NOT NULL)`, undefined); | ||
await queryRunner.query(`INSERT INTO "temporary_quotes"("tags", "quote", "quotedBy", "createdAt") SELECT "tags", "quote", "quotedBy", "createdAt" FROM "quotes"`, undefined); | ||
await queryRunner.query(`DROP TABLE "quotes"`, undefined); | ||
await queryRunner.query(`ALTER TABLE "temporary_quotes" RENAME TO "quotes"`, undefined); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "quotes" RENAME TO "temporary_quotes"`, undefined); | ||
await queryRunner.query(`CREATE TABLE "quotes" ("id" varchar PRIMARY KEY NOT NULL, "tags" text NOT NULL, "quote" varchar NOT NULL, "quotedBy" integer NOT NULL, "createdAt" bigint NOT NULL)`, undefined); | ||
await queryRunner.query(`INSERT INTO "quotes"("id", "tags", "quote", "quotedBy", "createdAt") SELECT "id", "tags", "quote", "quotedBy", "createdAt" FROM "temporary_quotes"`, undefined); | ||
await queryRunner.query(`DROP TABLE "temporary_quotes"`, undefined); | ||
await queryRunner.query(`ALTER TABLE "quotes" RENAME TO "temporary_quotes"`, undefined); | ||
await queryRunner.query(`CREATE TABLE "quotes" ("id" varchar PRIMARY KEY NOT NULL, "tags" text NOT NULL, "quote" varchar NOT NULL, "quotedBy" integer NOT NULL, "createdAt" bigint NOT NULL)`, undefined); | ||
await queryRunner.query(`INSERT INTO "quotes"("tags", "quote", "quotedBy", "createdAt") SELECT "tags", "quote", "quotedBy", "createdAt" FROM "temporary_quotes"`, undefined); | ||
await queryRunner.query(`DROP TABLE "temporary_quotes"`, undefined); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters