summary refs log tree commit diff
path: root/src/database/migration
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-06-30 19:38:31 +0200
committerRory& <root@rory.gay>2026-07-01 19:46:31 +0200
commitc6e7530b810a7bf1e6cf56c28647837ccdaef10f (patch)
tree5879ee466101d92692acb5efd86b27caa77ccad6 /src/database/migration
parentUpdate package.json to point to the right database.js (diff)
downloadserver-ts-c6e7530b810a7bf1e6cf56c28647837ccdaef10f.tar.xz
Emoji application migration, set explicit foreign key constraint names
Diffstat (limited to 'src/database/migration')
-rw-r--r--src/database/migration/postgres/1782839999040-ApplicationEmojis.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/database/migration/postgres/1782839999040-ApplicationEmojis.ts b/src/database/migration/postgres/1782839999040-ApplicationEmojis.ts
new file mode 100644

index 000000000..53610ca9f --- /dev/null +++ b/src/database/migration/postgres/1782839999040-ApplicationEmojis.ts
@@ -0,0 +1,25 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class ApplicationEmojis1782839999040 implements MigrationInterface { + name = "ApplicationEmojis1782839999040"; + + public async up(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(`ALTER TABLE "emojis" ADD "application_id" bigint`); + await queryRunner.query(`ALTER TABLE "emojis" DROP CONSTRAINT "FK_4b988e0db89d94cebcf07f598cc"`); + await queryRunner.query(`ALTER TABLE "emojis" ALTER COLUMN "guild_id" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "emojis" ADD CONSTRAINT "FK_emoji_guild_id" FOREIGN KEY ("guild_id") REFERENCES "guilds"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + await queryRunner.query( + `ALTER TABLE "emojis" ADD CONSTRAINT "FK_emoji_application_id" FOREIGN KEY ("application_id") REFERENCES "applications"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + } + + public async down(queryRunner: QueryRunner): Promise<void> { + await queryRunner.query(`ALTER TABLE "emojis" DROP CONSTRAINT "FK_emoji_application_id"`); + await queryRunner.query(`ALTER TABLE "emojis" DROP CONSTRAINT "FK_emoji_guild_id"`); + await queryRunner.query(`ALTER TABLE "emojis" ALTER COLUMN "guild_id" SET NOT NULL`); + await queryRunner.query( + `ALTER TABLE "emojis" ADD CONSTRAINT "FK_4b988e0db89d94cebcf07f598cc" FOREIGN KEY ("guild_id") REFERENCES "guilds"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + await queryRunner.query(`ALTER TABLE "emojis" DROP COLUMN "application_id"`); + } +}