From 7a726e786ce7618bae0cce8e345533528315582d Mon Sep 17 00:00:00 2001 From: TomatoCake <60300461+DEVTomatoCake@users.noreply.github.com> Date: Wed, 14 Aug 2024 16:22:14 +0200 Subject: [PATCH] Add migrations for webhook source_channel_id --- .../1723644478176-webhookSourceChannel.ts | 23 +++++++++++++++++++ .../1723644478176-webhookSourceChannel.ts | 23 +++++++++++++++++++ .../1723644478176-webhookSourceChannel.ts | 23 +++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 src/util/migration/mariadb/1723644478176-webhookSourceChannel.ts create mode 100644 src/util/migration/mysql/1723644478176-webhookSourceChannel.ts create mode 100644 src/util/migration/postgres/1723644478176-webhookSourceChannel.ts diff --git a/src/util/migration/mariadb/1723644478176-webhookSourceChannel.ts b/src/util/migration/mariadb/1723644478176-webhookSourceChannel.ts new file mode 100644 index 00000000..ac2b1799 --- /dev/null +++ b/src/util/migration/mariadb/1723644478176-webhookSourceChannel.ts @@ -0,0 +1,23 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class WebhookSourceChannel1723644478176 implements MigrationInterface { + name = "WebhookSourceChannel1723644478176"; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + "ALTER TABLE `webhooks` ADD COLUMN `source_channel_id` VARCHAR(255) NULL DEFAULT NULL AFTER `source_guild_id`", + ); + await queryRunner.query( + "ALTER TABLE `webhooks` ADD CONSTRAINT `FK_d64f38834fa676f6caa4786ddd6` FOREIGN KEY (`source_channel_id`) REFERENCES `channels` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE", + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + "ALTER TABLE `webhooks` DROP FOREIGN KEY `FK_d64f38834fa676f6caa4786ddd6`", + ); + await queryRunner.query( + "ALTER TABLE `webhooks` DROP COLUMN `source_channel_id`", + ); + } +} diff --git a/src/util/migration/mysql/1723644478176-webhookSourceChannel.ts b/src/util/migration/mysql/1723644478176-webhookSourceChannel.ts new file mode 100644 index 00000000..ac2b1799 --- /dev/null +++ b/src/util/migration/mysql/1723644478176-webhookSourceChannel.ts @@ -0,0 +1,23 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class WebhookSourceChannel1723644478176 implements MigrationInterface { + name = "WebhookSourceChannel1723644478176"; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + "ALTER TABLE `webhooks` ADD COLUMN `source_channel_id` VARCHAR(255) NULL DEFAULT NULL AFTER `source_guild_id`", + ); + await queryRunner.query( + "ALTER TABLE `webhooks` ADD CONSTRAINT `FK_d64f38834fa676f6caa4786ddd6` FOREIGN KEY (`source_channel_id`) REFERENCES `channels` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE", + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + "ALTER TABLE `webhooks` DROP FOREIGN KEY `FK_d64f38834fa676f6caa4786ddd6`", + ); + await queryRunner.query( + "ALTER TABLE `webhooks` DROP COLUMN `source_channel_id`", + ); + } +} diff --git a/src/util/migration/postgres/1723644478176-webhookSourceChannel.ts b/src/util/migration/postgres/1723644478176-webhookSourceChannel.ts new file mode 100644 index 00000000..babcf488 --- /dev/null +++ b/src/util/migration/postgres/1723644478176-webhookSourceChannel.ts @@ -0,0 +1,23 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class WebhookSourceChannel1723644478176 implements MigrationInterface { + name = "WebhookSourceChannel1723644478176"; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + "ALTER TABLE webhooks ADD COLUMN source_channel_id VARCHAR(255) NULL DEFAULT NULL AFTER source_guild_id", + ); + await queryRunner.query( + "ALTER TABLE webhooks ADD CONSTRAINT FK_d64f38834fa676f6caa4786ddd6 FOREIGN KEY (source_channel_id) REFERENCES channels (id) ON UPDATE NO ACTION ON DELETE CASCADE", + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + "ALTER TABLE webhooks DROP CONSTRAINT FK_d64f38834fa676f6caa4786ddd6", + ); + await queryRunner.query( + "ALTER TABLE webhooks DROP COLUMN source_channel_id", + ); + } +}