diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-10-10 14:09:54 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-10-10 14:09:54 +0200 |
commit | ebb0f567d5b010951bc0b9b35ffa002135528e1a (patch) | |
tree | b47c7e2a3a588fd8207cf7b8e6d3cb3cec269168 /util/src/migrations | |
parent | :bug: fix cdn route not working without hash (diff) | |
download | server-ebb0f567d5b010951bc0b9b35ffa002135528e1a.tar.xz |
:art: emoji db migration
Diffstat (limited to 'util/src/migrations')
-rw-r--r-- | util/src/migrations/1633864260873-EmojiRoles.ts | 13 | ||||
-rw-r--r-- | util/src/migrations/1633864669243-EmojiUser.ts | 23 |
2 files changed, 36 insertions, 0 deletions
diff --git a/util/src/migrations/1633864260873-EmojiRoles.ts b/util/src/migrations/1633864260873-EmojiRoles.ts new file mode 100644 index 00000000..f0d709f2 --- /dev/null +++ b/util/src/migrations/1633864260873-EmojiRoles.ts @@ -0,0 +1,13 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class EmojiRoles1633864260873 implements MigrationInterface { + name = "EmojiRoles1633864260873"; + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(`ALTER TABLE "emojis" ADD "roles" text NOT NULL DEFAULT ''`); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(`ALTER TABLE "emojis" DROP COLUMN column_name "roles"`); + } +} diff --git a/util/src/migrations/1633864669243-EmojiUser.ts b/util/src/migrations/1633864669243-EmojiUser.ts new file mode 100644 index 00000000..982405d7 --- /dev/null +++ b/util/src/migrations/1633864669243-EmojiUser.ts @@ -0,0 +1,23 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class EmojiUser1633864669243 implements MigrationInterface { + name = "EmojiUser1633864669243"; + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(`ALTER TABLE "emojis" ADD "user_id" varchar`); + try { + await queryRunner.query( + `ALTER TABLE "emojis" ADD CONSTRAINT FK_fa7ddd5f9a214e28ce596548421 FOREIGN KEY (user_id) REFERENCES users(id)` + ); + } catch (error) { + console.error( + "sqlite doesn't support altering foreign keys: https://stackoverflow.com/questions/1884818/how-do-i-add-a-foreign-key-to-an-existing-sqlite-table" + ); + } + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(`ALTER TABLE "emojis" DROP COLUMN column_name "user_id"`); + await queryRunner.query(`ALTER TABLE "emojis" DROP CONSTRAINT FK_fa7ddd5f9a214e28ce596548421`); + } +} |