diff --git a/src/util/migration/postgres/1673609867556-templateDeleteCascade.ts b/src/util/migration/postgres/1673609867556-templateDeleteCascade.ts index 504ed55..ba0025d 100644 --- a/src/util/migration/postgres/1673609867556-templateDeleteCascade.ts +++ b/src/util/migration/postgres/1673609867556-templateDeleteCascade.ts @@ -22,18 +22,14 @@ name = "templateDeleteCascade1673609867556"; public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "templates" DROP CONSTRAINT "FK_445d00eaaea0e60a017a5ed0c11"`, - ); + await queryRunner.query(`ALTER TABLE "templates" DROP CONSTRAINT "FK_445d00eaaea0e60a017a5ed0c11"`); await queryRunner.query( `ALTER TABLE "templates" ADD CONSTRAINT "FK_445d00eaaea0e60a017a5ed0c11" FOREIGN KEY ("source_guild_id") REFERENCES "guilds"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, ); } public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "templates" DROP CONSTRAINT "FK_445d00eaaea0e60a017a5ed0c11"`, - ); + await queryRunner.query(`ALTER TABLE "templates" DROP CONSTRAINT "FK_445d00eaaea0e60a017a5ed0c11"`); await queryRunner.query( `ALTER TABLE "templates" ADD CONSTRAINT "FK_445d00eaaea0e60a017a5ed0c11" FOREIGN KEY ("source_guild_id") REFERENCES "guilds"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, ); diff --git a/src/util/migration/postgres/1675044825710-webauthn.ts b/src/util/migration/postgres/1675044825710-webauthn.ts index 4b32d6c..19a96b4 100644 --- a/src/util/migration/postgres/1675044825710-webauthn.ts +++ b/src/util/migration/postgres/1675044825710-webauthn.ts @@ -25,21 +25,15 @@ await queryRunner.query( `CREATE TABLE "security_keys" ("id" character varying NOT NULL, "user_id" character varying, "key_id" character varying NOT NULL, "public_key" character varying NOT NULL, "counter" integer NOT NULL, "name" character varying NOT NULL, CONSTRAINT "PK_6e95cdd91779e7cca06d1fff89c" PRIMARY KEY ("id"))`, ); - await queryRunner.query( - `ALTER TABLE "users" ADD "webauthn_enabled" boolean NOT NULL DEFAULT false`, - ); + await queryRunner.query(`ALTER TABLE "users" ADD "webauthn_enabled" boolean NOT NULL DEFAULT false`); await queryRunner.query( `ALTER TABLE "security_keys" ADD CONSTRAINT "FK_24c97d0771cafedce6d7163eaad" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, ); } public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "security_keys" DROP CONSTRAINT "FK_24c97d0771cafedce6d7163eaad"`, - ); - await queryRunner.query( - `ALTER TABLE "users" DROP COLUMN "webauthn_enabled"`, - ); + await queryRunner.query(`ALTER TABLE "security_keys" DROP CONSTRAINT "FK_24c97d0771cafedce6d7163eaad"`); + await queryRunner.query(`ALTER TABLE "users" DROP COLUMN "webauthn_enabled"`); await queryRunner.query(`DROP TABLE "security_keys"`); } } diff --git a/src/util/migration/postgres/1696420827239-guildChannelOrdering.ts b/src/util/migration/postgres/1696420827239-guildChannelOrdering.ts index 1623f98..4848ffd 100644 --- a/src/util/migration/postgres/1696420827239-guildChannelOrdering.ts +++ b/src/util/migration/postgres/1696420827239-guildChannelOrdering.ts @@ -4,31 +4,16 @@ name = "guildChannelOrdering1696420827239"; public async up(queryRunner: QueryRunner): Promise { - const guilds = await queryRunner.query( - `SELECT id FROM guilds`, - undefined, - true, - ); + const guilds = await queryRunner.query(`SELECT id FROM guilds`, undefined, true); - await queryRunner.query( - `ALTER TABLE guilds ADD channel_ordering text NOT NULL DEFAULT '[]'`, - ); + await queryRunner.query(`ALTER TABLE guilds ADD channel_ordering text NOT NULL DEFAULT '[]'`); for (const guild_id of guilds.records.map((x) => x.id)) { - const channels: Array<{ position: number; id: string }> = ( - await queryRunner.query( - `SELECT id, position FROM channels WHERE guild_id = $1`, - [guild_id], - true, - ) - ).records; + const channels: Array<{ position: number; id: string }> = (await queryRunner.query(`SELECT id, position FROM channels WHERE guild_id = $1`, [guild_id], true)).records; channels.sort((a, b) => a.position - b.position); - await queryRunner.query( - `UPDATE guilds SET channel_ordering = $1 WHERE id = $2`, - [JSON.stringify(channels.map((x) => x.id)), guild_id], - ); + await queryRunner.query(`UPDATE guilds SET channel_ordering = $1 WHERE id = $2`, [JSON.stringify(channels.map((x) => x.id)), guild_id]); } await queryRunner.query(`ALTER TABLE channels DROP COLUMN position`); @@ -37,26 +22,17 @@ public async down(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE channels ADD position integer NOT NULL DEFAULT 0`); - const guilds = await queryRunner.query( - `SELECT id, channel_ordering FROM guilds`, - undefined, - true, - ); + const guilds = await queryRunner.query(`SELECT id, channel_ordering FROM guilds`, undefined, true); for (const guild of guilds.records) { const channel_ordering: string[] = JSON.parse(guild.channel_ordering); for (let i = 0; i < channel_ordering.length; i++) { const channel_id = channel_ordering[i]; - await queryRunner.query( - `UPDATE channels SET position = $1 WHERE id = $2`, - [i, channel_id], - ); + await queryRunner.query(`UPDATE channels SET position = $1 WHERE id = $2`, [i, channel_id]); } } - await queryRunner.query( - `ALTER TABLE guilds DROP COLUMN channel_ordering`, - ); + await queryRunner.query(`ALTER TABLE guilds DROP COLUMN channel_ordering`); } } diff --git a/src/util/migration/postgres/1713116476900-messageFlagsNotNull.ts b/src/util/migration/postgres/1713116476900-messageFlagsNotNull.ts index 543a7ce..afec685 100644 --- a/src/util/migration/postgres/1713116476900-messageFlagsNotNull.ts +++ b/src/util/migration/postgres/1713116476900-messageFlagsNotNull.ts @@ -4,28 +4,16 @@ name = "MessageFlagsNotNull1713116476900"; public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - "ALTER TABLE messages RENAME COLUMN flags TO flags_old;", - ); - await queryRunner.query( - "ALTER TABLE messages ADD COLUMN flags integer NOT NULL DEFAULT 0;", - ); - await queryRunner.query( - "UPDATE messages SET flags = COALESCE(flags_old, 0);", - ); + await queryRunner.query("ALTER TABLE messages RENAME COLUMN flags TO flags_old;"); + await queryRunner.query("ALTER TABLE messages ADD COLUMN flags integer NOT NULL DEFAULT 0;"); + await queryRunner.query("UPDATE messages SET flags = COALESCE(flags_old, 0);"); await queryRunner.query("ALTER TABLE messages DROP COLUMN flags_old;"); } public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - "ALTER TABLE messages RENAME COLUMN flags TO flags_new;", - ); - await queryRunner.query( - "ALTER TABLE messages ADD COLUMN flags integer;", - ); - await queryRunner.query( - "UPDATE messages SET flags = flags_new;", - ); + await queryRunner.query("ALTER TABLE messages RENAME COLUMN flags TO flags_new;"); + await queryRunner.query("ALTER TABLE messages ADD COLUMN flags integer;"); + await queryRunner.query("UPDATE messages SET flags = flags_new;"); await queryRunner.query("ALTER TABLE messages DROP COLUMN flags_new;"); } } diff --git a/src/util/migration/postgres/1719776735000-newUserSettings.ts b/src/util/migration/postgres/1719776735000-newUserSettings.ts index dbee0b0..d4142d2 100644 --- a/src/util/migration/postgres/1719776735000-newUserSettings.ts +++ b/src/util/migration/postgres/1719776735000-newUserSettings.ts @@ -4,20 +4,12 @@ name = "NewUserSettings1719776735000"; public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - "ALTER TABLE user_settings ADD COLUMN friend_discovery_flags integer DEFAULT 0;", - ); - await queryRunner.query( - "ALTER TABLE user_settings ADD COLUMN view_nsfw_guilds boolean DEFAULT true;", - ); + await queryRunner.query("ALTER TABLE user_settings ADD COLUMN friend_discovery_flags integer DEFAULT 0;"); + await queryRunner.query("ALTER TABLE user_settings ADD COLUMN view_nsfw_guilds boolean DEFAULT true;"); } public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - "ALTER TABLE user_settings DROP COLUMN friend_discovery_flags;", - ); - await queryRunner.query( - "ALTER TABLE user_settings DROP COLUMN view_nsfw_guilds;", - ); + await queryRunner.query("ALTER TABLE user_settings DROP COLUMN friend_discovery_flags;"); + await queryRunner.query("ALTER TABLE user_settings DROP COLUMN view_nsfw_guilds;"); } } diff --git a/src/util/migration/postgres/1721298824927-webhookMessageProperties.ts b/src/util/migration/postgres/1721298824927-webhookMessageProperties.ts index bd603f1..46c507d 100644 --- a/src/util/migration/postgres/1721298824927-webhookMessageProperties.ts +++ b/src/util/migration/postgres/1721298824927-webhookMessageProperties.ts @@ -1,8 +1,6 @@ import { MigrationInterface, QueryRunner } from "typeorm"; -export class WebhookMessageProperties1721298824927 - implements MigrationInterface -{ +export class WebhookMessageProperties1721298824927 implements MigrationInterface { name = "WebhookMessageProperties1721298824927"; public async up(queryRunner: QueryRunner): Promise { diff --git a/src/util/migration/postgres/1723347738541-client_status.ts b/src/util/migration/postgres/1723347738541-client_status.ts index 35d9391..c16e049 100644 --- a/src/util/migration/postgres/1723347738541-client_status.ts +++ b/src/util/migration/postgres/1723347738541-client_status.ts @@ -4,14 +4,10 @@ name = "client_status1723347738541"; public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - "ALTER TABLE sessions ADD client_status text NULL", - ); + await queryRunner.query("ALTER TABLE sessions ADD client_status text NULL"); } public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - "ALTER TABLE sessions DROP COLUMN client_status", - ); + await queryRunner.query("ALTER TABLE sessions DROP COLUMN client_status"); } } diff --git a/src/util/migration/postgres/1723644478176-webhookSourceChannel.ts b/src/util/migration/postgres/1723644478176-webhookSourceChannel.ts index 63ce961..12a726f 100644 --- a/src/util/migration/postgres/1723644478176-webhookSourceChannel.ts +++ b/src/util/migration/postgres/1723644478176-webhookSourceChannel.ts @@ -4,20 +4,14 @@ name = "WebhookSourceChannel1723644478176"; public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - "ALTER TABLE webhooks ADD COLUMN source_channel_id VARCHAR(255) NULL DEFAULT NULL", - ); + await queryRunner.query("ALTER TABLE webhooks ADD COLUMN source_channel_id VARCHAR(255) NULL DEFAULT NULL"); 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", - ); + await queryRunner.query("ALTER TABLE webhooks DROP CONSTRAINT FK_d64f38834fa676f6caa4786ddd6"); + await queryRunner.query("ALTER TABLE webhooks DROP COLUMN source_channel_id"); } } diff --git a/src/util/migration/postgres/1724477620293-teamMemberRole.ts b/src/util/migration/postgres/1724477620293-teamMemberRole.ts index d3276d9..9bc92cb 100644 --- a/src/util/migration/postgres/1724477620293-teamMemberRole.ts +++ b/src/util/migration/postgres/1724477620293-teamMemberRole.ts @@ -4,9 +4,7 @@ name = "TeamMemberRole1724477620293"; public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - "ALTER TABLE team_members ADD COLUMN role text NOT NULL", - ); + await queryRunner.query("ALTER TABLE team_members ADD COLUMN role text NOT NULL"); } public async down(queryRunner: QueryRunner): Promise { diff --git a/src/util/migration/postgres/1725090962922-applicationProperties.ts b/src/util/migration/postgres/1725090962922-applicationProperties.ts index 8e3ea46..e396014 100644 --- a/src/util/migration/postgres/1725090962922-applicationProperties.ts +++ b/src/util/migration/postgres/1725090962922-applicationProperties.ts @@ -4,20 +4,12 @@ name = "ApplicationProperties1725090962922"; public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - "ALTER TABLE applications ADD COLUMN guild_id TEXT NULL DEFAULT NULL", - ); - await queryRunner.query( - "ALTER TABLE applications ADD COLUMN custom_install_url TEXT NULL DEFAULT NULL", - ); + await queryRunner.query("ALTER TABLE applications ADD COLUMN guild_id TEXT NULL DEFAULT NULL"); + await queryRunner.query("ALTER TABLE applications ADD COLUMN custom_install_url TEXT NULL DEFAULT NULL"); } public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - "ALTER TABLE applications DROP COLUMN guild_id", - ); - await queryRunner.query( - "ALTER TABLE applications DROP COLUMN custom_install_url", - ); + await queryRunner.query("ALTER TABLE applications DROP COLUMN guild_id"); + await queryRunner.query("ALTER TABLE applications DROP COLUMN custom_install_url"); } } diff --git a/src/util/migration/postgres/1745625724865-voice.ts b/src/util/migration/postgres/1745625724865-voice.ts index d9f7101..2310ec2 100644 --- a/src/util/migration/postgres/1745625724865-voice.ts +++ b/src/util/migration/postgres/1745625724865-voice.ts @@ -25,18 +25,10 @@ } public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "stream_sessions" DROP CONSTRAINT "FK_13ae5c29aff4d0890c54179511a"`, - ); - await queryRunner.query( - `ALTER TABLE "stream_sessions" DROP CONSTRAINT "FK_8b5a028a34dae9ee54af37c9c32"`, - ); - await queryRunner.query( - `ALTER TABLE "streams" DROP CONSTRAINT "FK_5101f0cded27ff0aae78fc4eed7"`, - ); - await queryRunner.query( - `ALTER TABLE "streams" DROP CONSTRAINT "FK_1b566f9b54d1cda271da53ac82f"`, - ); + await queryRunner.query(`ALTER TABLE "stream_sessions" DROP CONSTRAINT "FK_13ae5c29aff4d0890c54179511a"`); + await queryRunner.query(`ALTER TABLE "stream_sessions" DROP CONSTRAINT "FK_8b5a028a34dae9ee54af37c9c32"`); + await queryRunner.query(`ALTER TABLE "streams" DROP CONSTRAINT "FK_5101f0cded27ff0aae78fc4eed7"`); + await queryRunner.query(`ALTER TABLE "streams" DROP CONSTRAINT "FK_1b566f9b54d1cda271da53ac82f"`); await queryRunner.query(`DROP TABLE "stream_sessions"`); await queryRunner.query(`DROP TABLE "streams"`); } diff --git a/src/util/migration/postgres/1752157979333-UserSettingsProtos.ts b/src/util/migration/postgres/1752157979333-UserSettingsProtos.ts index 0633e14..d7cf546 100644 --- a/src/util/migration/postgres/1752157979333-UserSettingsProtos.ts +++ b/src/util/migration/postgres/1752157979333-UserSettingsProtos.ts @@ -1,17 +1,20 @@ import { MigrationInterface, QueryRunner } from "typeorm"; export class UserSettingsProtos1752157979333 implements MigrationInterface { - name = 'UserSettingsProtos1752157979333' + name = "UserSettingsProtos1752157979333"; - public async up(queryRunner: QueryRunner): Promise { + public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(`DROP TABLE IF EXISTS "user_settings_protos"`); - await queryRunner.query(`CREATE TABLE "user_settings_protos" ("user_id" character varying NOT NULL, "userSettings" text, "frecencySettings" text, CONSTRAINT "PK_8ff3d1961a48b693810c9f99853" PRIMARY KEY ("user_id"))`); - await queryRunner.query(`ALTER TABLE "user_settings_protos" ADD CONSTRAINT "FK_8ff3d1961a48b693810c9f99853" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } + await queryRunner.query( + `CREATE TABLE "user_settings_protos" ("user_id" character varying NOT NULL, "userSettings" text, "frecencySettings" text, CONSTRAINT "PK_8ff3d1961a48b693810c9f99853" PRIMARY KEY ("user_id"))`, + ); + await queryRunner.query( + `ALTER TABLE "user_settings_protos" ADD CONSTRAINT "FK_8ff3d1961a48b693810c9f99853" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + ); + } - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "user_settings_protos" DROP CONSTRAINT "FK_8ff3d1961a48b693810c9f99853"`); - await queryRunner.query(`DROP TABLE "user_settings_protos"`); - } - + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "user_settings_protos" DROP CONSTRAINT "FK_8ff3d1961a48b693810c9f99853"`); + await queryRunner.query(`DROP TABLE "user_settings_protos"`); + } } diff --git a/src/util/migration/postgres/1752321571508-RoleColors.ts b/src/util/migration/postgres/1752321571508-RoleColors.ts index beb4206..c88476e 100644 --- a/src/util/migration/postgres/1752321571508-RoleColors.ts +++ b/src/util/migration/postgres/1752321571508-RoleColors.ts @@ -1,16 +1,15 @@ import { MigrationInterface, QueryRunner } from "typeorm"; export class RoleColors1752321571508 implements MigrationInterface { - name = 'RoleColors1752321571508' + name = "RoleColors1752321571508"; - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "roles" ADD "colors" text`); + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "roles" ADD "colors" text`); await queryRunner.query(`UPDATE "roles" SET "colors" = jsonb_build_object('primary_color', "color") WHERE "colors" IS NULL`); await queryRunner.query(`ALTER TABLE "roles" ALTER COLUMN "colors" SET NOT NULL`); } - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "roles" DROP COLUMN "colors"`); - } - + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "roles" DROP COLUMN "colors"`); + } } diff --git a/src/util/migration/postgres/1752383879533-message_pinned_at.ts b/src/util/migration/postgres/1752383879533-message_pinned_at.ts index 9f71f5f..b517477 100644 --- a/src/util/migration/postgres/1752383879533-message_pinned_at.ts +++ b/src/util/migration/postgres/1752383879533-message_pinned_at.ts @@ -4,22 +4,14 @@ name = "MessagePinnedAt1752383879533"; public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "messages" ADD "pinned_at" TIMESTAMP`, - ); - await queryRunner.query( - `UPDATE "messages" SET "pinned_at" = NOW() WHERE "pinned" = true`, - ); + await queryRunner.query(`ALTER TABLE "messages" ADD "pinned_at" TIMESTAMP`); + await queryRunner.query(`UPDATE "messages" SET "pinned_at" = NOW() WHERE "pinned" = true`); await queryRunner.query(`ALTER TABLE "messages" DROP COLUMN "pinned"`); } public async down(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "messages" ADD "pinned" boolean`); - await queryRunner.query( - `UPDATE "messages" SET "pinned" = true WHERE "pinned_at" IS NOT NULL`, - ); - await queryRunner.query( - `ALTER TABLE "messages" DROP COLUMN "pinned_at"`, - ); + await queryRunner.query(`UPDATE "messages" SET "pinned" = true WHERE "pinned_at" IS NOT NULL`); + await queryRunner.query(`ALTER TABLE "messages" DROP COLUMN "pinned_at"`); } } diff --git a/src/util/migration/postgres/1753639700904-Automod.ts b/src/util/migration/postgres/1753639700904-Automod.ts index d12c956..2df78cc 100644 --- a/src/util/migration/postgres/1753639700904-Automod.ts +++ b/src/util/migration/postgres/1753639700904-Automod.ts @@ -1,16 +1,19 @@ import { MigrationInterface, QueryRunner } from "typeorm"; export class Automod1753639700904 implements MigrationInterface { - name = 'Automod1753639700904' + name = "Automod1753639700904"; - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE "automod_rules" ("id" character varying NOT NULL, "enabled" boolean NOT NULL, "event_type" integer NOT NULL, "exempt_channels" text NOT NULL, "exempt_roles" text NOT NULL, "guild_id" character varying NOT NULL, "name" character varying NOT NULL, "position" integer NOT NULL, "trigger_type" integer NOT NULL, "trigger_metadata" text, "actions" text NOT NULL, "creator_id" character varying, CONSTRAINT "PK_99789ae863507f5aed9e58d7866" PRIMARY KEY ("id"))`); - await queryRunner.query(`ALTER TABLE "automod_rules" ADD CONSTRAINT "FK_12d3d60b961393d310429c062b7" FOREIGN KEY ("creator_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - } + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE "automod_rules" ("id" character varying NOT NULL, "enabled" boolean NOT NULL, "event_type" integer NOT NULL, "exempt_channels" text NOT NULL, "exempt_roles" text NOT NULL, "guild_id" character varying NOT NULL, "name" character varying NOT NULL, "position" integer NOT NULL, "trigger_type" integer NOT NULL, "trigger_metadata" text, "actions" text NOT NULL, "creator_id" character varying, CONSTRAINT "PK_99789ae863507f5aed9e58d7866" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `ALTER TABLE "automod_rules" ADD CONSTRAINT "FK_12d3d60b961393d310429c062b7" FOREIGN KEY ("creator_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + } - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "automod_rules" DROP CONSTRAINT "FK_12d3d60b961393d310429c062b7"`); - await queryRunner.query(`DROP TABLE "automod_rules"`); - } - + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "automod_rules" DROP CONSTRAINT "FK_12d3d60b961393d310429c062b7"`); + await queryRunner.query(`DROP TABLE "automod_rules"`); + } } diff --git a/src/util/migration/postgres/1758654246197-CloudAttachments.ts b/src/util/migration/postgres/1758654246197-CloudAttachments.ts index 03f745b..6e462e0 100644 --- a/src/util/migration/postgres/1758654246197-CloudAttachments.ts +++ b/src/util/migration/postgres/1758654246197-CloudAttachments.ts @@ -1,18 +1,23 @@ import { MigrationInterface, QueryRunner } from "typeorm"; export class CloudAttachments1758654246197 implements MigrationInterface { - name = 'CloudAttachments1758654246197' + name = "CloudAttachments1758654246197"; - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE "cloud_attachments" ("id" character varying NOT NULL, "user_id" character varying, "channel_id" character varying, "upload_filename" character varying NOT NULL, "user_attachment_id" character varying, "user_filename" character varying NOT NULL, "user_file_size" integer, "user_original_content_type" character varying, "user_is_clip" boolean, "size" integer, "height" integer, "width" integer, "content_type" character varying, "userId" character varying, "channelId" character varying, CONSTRAINT "PK_5794827a3ee7c9318612dcb70c8" PRIMARY KEY ("id"))`); - await queryRunner.query(`ALTER TABLE "cloud_attachments" ADD CONSTRAINT "FK_e6b32df2004e8ad0f488b4a2019" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cloud_attachments" ADD CONSTRAINT "FK_cab965a18f8ca30293bff3d50a8" FOREIGN KEY ("channelId") REFERENCES "channels"("id") ON DELETE SET NULL ON UPDATE NO ACTION`); - } + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE "cloud_attachments" ("id" character varying NOT NULL, "user_id" character varying, "channel_id" character varying, "upload_filename" character varying NOT NULL, "user_attachment_id" character varying, "user_filename" character varying NOT NULL, "user_file_size" integer, "user_original_content_type" character varying, "user_is_clip" boolean, "size" integer, "height" integer, "width" integer, "content_type" character varying, "userId" character varying, "channelId" character varying, CONSTRAINT "PK_5794827a3ee7c9318612dcb70c8" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `ALTER TABLE "cloud_attachments" ADD CONSTRAINT "FK_e6b32df2004e8ad0f488b4a2019" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "cloud_attachments" ADD CONSTRAINT "FK_cab965a18f8ca30293bff3d50a8" FOREIGN KEY ("channelId") REFERENCES "channels"("id") ON DELETE SET NULL ON UPDATE NO ACTION`, + ); + } - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP CONSTRAINT "FK_cab965a18f8ca30293bff3d50a8"`); - await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP CONSTRAINT "FK_e6b32df2004e8ad0f488b4a2019"`); - await queryRunner.query(`DROP TABLE "cloud_attachments"`); - } - + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP CONSTRAINT "FK_cab965a18f8ca30293bff3d50a8"`); + await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP CONSTRAINT "FK_e6b32df2004e8ad0f488b4a2019"`); + await queryRunner.query(`DROP TABLE "cloud_attachments"`); + } } diff --git a/src/util/migration/postgres/1758654621365-CloudAttachmentsFixIdRefs.ts b/src/util/migration/postgres/1758654621365-CloudAttachmentsFixIdRefs.ts index b3be7ab..6ad6300 100644 --- a/src/util/migration/postgres/1758654621365-CloudAttachmentsFixIdRefs.ts +++ b/src/util/migration/postgres/1758654621365-CloudAttachmentsFixIdRefs.ts @@ -1,24 +1,31 @@ import { MigrationInterface, QueryRunner } from "typeorm"; export class CloudAttachmentsFixIdRefs1758654621365 implements MigrationInterface { - name = 'CloudAttachmentsFixIdRefs1758654621365' + name = "CloudAttachmentsFixIdRefs1758654621365"; - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP CONSTRAINT "FK_cab965a18f8ca30293bff3d50a8"`); - await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP CONSTRAINT "FK_e6b32df2004e8ad0f488b4a2019"`); - await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP COLUMN "channelId"`); - await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP COLUMN "userId"`); - await queryRunner.query(`ALTER TABLE "cloud_attachments" ADD CONSTRAINT "FK_8bf8cc8767e48cb482ff644fce6" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cloud_attachments" ADD CONSTRAINT "FK_998d5fe91008ba5b09e1322104c" FOREIGN KEY ("channel_id") REFERENCES "channels"("id") ON DELETE SET NULL ON UPDATE NO ACTION`); - } + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP CONSTRAINT "FK_cab965a18f8ca30293bff3d50a8"`); + await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP CONSTRAINT "FK_e6b32df2004e8ad0f488b4a2019"`); + await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP COLUMN "channelId"`); + await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP COLUMN "userId"`); + await queryRunner.query( + `ALTER TABLE "cloud_attachments" ADD CONSTRAINT "FK_8bf8cc8767e48cb482ff644fce6" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "cloud_attachments" ADD CONSTRAINT "FK_998d5fe91008ba5b09e1322104c" FOREIGN KEY ("channel_id") REFERENCES "channels"("id") ON DELETE SET NULL ON UPDATE NO ACTION`, + ); + } - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP CONSTRAINT "FK_998d5fe91008ba5b09e1322104c"`); - await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP CONSTRAINT "FK_8bf8cc8767e48cb482ff644fce6"`); - await queryRunner.query(`ALTER TABLE "cloud_attachments" ADD "userId" character varying`); - await queryRunner.query(`ALTER TABLE "cloud_attachments" ADD "channelId" character varying`); - await queryRunner.query(`ALTER TABLE "cloud_attachments" ADD CONSTRAINT "FK_e6b32df2004e8ad0f488b4a2019" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "cloud_attachments" ADD CONSTRAINT "FK_cab965a18f8ca30293bff3d50a8" FOREIGN KEY ("channelId") REFERENCES "channels"("id") ON DELETE SET NULL ON UPDATE NO ACTION`); - } - + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP CONSTRAINT "FK_998d5fe91008ba5b09e1322104c"`); + await queryRunner.query(`ALTER TABLE "cloud_attachments" DROP CONSTRAINT "FK_8bf8cc8767e48cb482ff644fce6"`); + await queryRunner.query(`ALTER TABLE "cloud_attachments" ADD "userId" character varying`); + await queryRunner.query(`ALTER TABLE "cloud_attachments" ADD "channelId" character varying`); + await queryRunner.query( + `ALTER TABLE "cloud_attachments" ADD CONSTRAINT "FK_e6b32df2004e8ad0f488b4a2019" FOREIGN KEY ("userId") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "cloud_attachments" ADD CONSTRAINT "FK_cab965a18f8ca30293bff3d50a8" FOREIGN KEY ("channelId") REFERENCES "channels"("id") ON DELETE SET NULL ON UPDATE NO ACTION`, + ); + } } diff --git a/src/util/migration/postgres/1760622755598-ApplicationCommands.ts b/src/util/migration/postgres/1760622755598-ApplicationCommands.ts index f1a1073..e40a3a1 100644 --- a/src/util/migration/postgres/1760622755598-ApplicationCommands.ts +++ b/src/util/migration/postgres/1760622755598-ApplicationCommands.ts @@ -1,14 +1,15 @@ import { MigrationInterface, QueryRunner } from "typeorm"; export class ApplicationCommands1760622755598 implements MigrationInterface { - name = 'ApplicationCommands1760622755598' + name = "ApplicationCommands1760622755598"; - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE "application_commands" ("id" character varying NOT NULL, "type" integer NOT NULL DEFAULT '1', "application_id" character varying NOT NULL, "guild_id" character varying, "name" character varying NOT NULL, "name_localizations" text, "description" character varying NOT NULL, "description_localizations" text, "options" text, "default_member_permissions" character varying, "dm_permission" boolean NOT NULL DEFAULT true, "permissions" text, "nsfw" boolean NOT NULL DEFAULT false, "integration_types" text, "global_popularity_rank" integer NOT NULL DEFAULT '0', "contexts" text, "version" character varying NOT NULL DEFAULT '0', "handler" integer NOT NULL DEFAULT '0', CONSTRAINT "PK_0f73c2f025989c407947e1f75fe" PRIMARY KEY ("id"))`); - } + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE "application_commands" ("id" character varying NOT NULL, "type" integer NOT NULL DEFAULT '1', "application_id" character varying NOT NULL, "guild_id" character varying, "name" character varying NOT NULL, "name_localizations" text, "description" character varying NOT NULL, "description_localizations" text, "options" text, "default_member_permissions" character varying, "dm_permission" boolean NOT NULL DEFAULT true, "permissions" text, "nsfw" boolean NOT NULL DEFAULT false, "integration_types" text, "global_popularity_rank" integer NOT NULL DEFAULT '0', "contexts" text, "version" character varying NOT NULL DEFAULT '0', "handler" integer NOT NULL DEFAULT '0', CONSTRAINT "PK_0f73c2f025989c407947e1f75fe" PRIMARY KEY ("id"))`, + ); + } - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`DROP TABLE "application_commands"`); - } - + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP TABLE "application_commands"`); + } } diff --git a/src/util/migration/postgres/1760622755599-ReconcileMigrationAttempts.ts b/src/util/migration/postgres/1760622755599-ReconcileMigrationAttempts.ts index 7360305..27a2027 100644 --- a/src/util/migration/postgres/1760622755599-ReconcileMigrationAttempts.ts +++ b/src/util/migration/postgres/1760622755599-ReconcileMigrationAttempts.ts @@ -1,54 +1,57 @@ import { MigrationInterface, QueryRunner } from "typeorm"; export class ReconcileMigrationAttempts1760622755598 implements MigrationInterface { - name = 'ReconcileMigrationAttempts1760622755598' + name = "ReconcileMigrationAttempts1760622755598"; - public async up(queryRunner: QueryRunner): Promise { + public async up(queryRunner: QueryRunner): Promise { // doesnt work because initial setup is syncDb() - //await queryRunner.query(`ALTER TABLE "webhooks" DROP CONSTRAINT "fk_d64f38834fa676f6caa4786ddd6"`); - await queryRunner.query(`ALTER TABLE "webhooks" ALTER COLUMN "source_channel_id" TYPE character varying`); - await queryRunner.query(`ALTER TABLE "messages" ALTER COLUMN "username" TYPE character varying`); - await queryRunner.query(`ALTER TABLE "messages" ALTER COLUMN "avatar" TYPE character varying`); - await queryRunner.query(`ALTER TABLE "channels" ALTER COLUMN "default_thread_rate_limit_per_user" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "client_status" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "user_settings" ALTER COLUMN "friend_discovery_flags" DROP DEFAULT`); - await queryRunner.query(`ALTER TABLE "user_settings" ALTER COLUMN "view_nsfw_guilds" DROP DEFAULT`); - await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "flags" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "public_flags" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "purchased_flags" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "team_members" ALTER COLUMN "role" TYPE character varying`); - await queryRunner.query(`ALTER TABLE "team_members" ALTER COLUMN "role" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "applications" ALTER COLUMN "guild_id" TYPE character varying`); - await queryRunner.query(`ALTER TABLE "applications" ALTER COLUMN "custom_install_url" TYPE character varying`); - await queryRunner.query(`ALTER TABLE "categories" ALTER COLUMN "icon" TYPE character varying`); - await queryRunner.query(`ALTER TABLE "user_settings_protos" ALTER COLUMN "userSettings" TYPE character varying`); - await queryRunner.query(`ALTER TABLE "user_settings_protos" ALTER COLUMN "frecencySettings" TYPE character varying`); - await queryRunner.query(`ALTER TABLE "webhooks" ADD CONSTRAINT "FK_4495b7032a33c6b8b605d030398" FOREIGN KEY ("source_channel_id") REFERENCES "channels"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "applications" ADD CONSTRAINT "FK_e5bf78cdbbe9ba91062d74c5aba" FOREIGN KEY ("guild_id") REFERENCES "guilds"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } + //await queryRunner.query(`ALTER TABLE "webhooks" DROP CONSTRAINT "fk_d64f38834fa676f6caa4786ddd6"`); + await queryRunner.query(`ALTER TABLE "webhooks" ALTER COLUMN "source_channel_id" TYPE character varying`); + await queryRunner.query(`ALTER TABLE "messages" ALTER COLUMN "username" TYPE character varying`); + await queryRunner.query(`ALTER TABLE "messages" ALTER COLUMN "avatar" TYPE character varying`); + await queryRunner.query(`ALTER TABLE "channels" ALTER COLUMN "default_thread_rate_limit_per_user" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "client_status" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "user_settings" ALTER COLUMN "friend_discovery_flags" DROP DEFAULT`); + await queryRunner.query(`ALTER TABLE "user_settings" ALTER COLUMN "view_nsfw_guilds" DROP DEFAULT`); + await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "flags" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "public_flags" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "purchased_flags" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "team_members" ALTER COLUMN "role" TYPE character varying`); + await queryRunner.query(`ALTER TABLE "team_members" ALTER COLUMN "role" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "applications" ALTER COLUMN "guild_id" TYPE character varying`); + await queryRunner.query(`ALTER TABLE "applications" ALTER COLUMN "custom_install_url" TYPE character varying`); + await queryRunner.query(`ALTER TABLE "categories" ALTER COLUMN "icon" TYPE character varying`); + await queryRunner.query(`ALTER TABLE "user_settings_protos" ALTER COLUMN "userSettings" TYPE character varying`); + await queryRunner.query(`ALTER TABLE "user_settings_protos" ALTER COLUMN "frecencySettings" TYPE character varying`); + await queryRunner.query( + `ALTER TABLE "webhooks" ADD CONSTRAINT "FK_4495b7032a33c6b8b605d030398" FOREIGN KEY ("source_channel_id") REFERENCES "channels"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "applications" ADD CONSTRAINT "FK_e5bf78cdbbe9ba91062d74c5aba" FOREIGN KEY ("guild_id") REFERENCES "guilds"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, + ); + } - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "applications" DROP CONSTRAINT "FK_e5bf78cdbbe9ba91062d74c5aba"`); - await queryRunner.query(`ALTER TABLE "webhooks" DROP CONSTRAINT "FK_4495b7032a33c6b8b605d030398"`); - await queryRunner.query(`ALTER TABLE "user_settings_protos" ALTER COLUMN "frecencySettings" TYPE text`); - await queryRunner.query(`ALTER TABLE "user_settings_protos" ALTER COLUMN "userSettings" TYPE text`); - await queryRunner.query(`ALTER TABLE "categories" ALTER COLUMN "icon" TYPE text`); - await queryRunner.query(`ALTER TABLE "applications" ALTER COLUMN "custom_install_url" TYPE text`); - await queryRunner.query(`ALTER TABLE "applications" ALTER COLUMN "guild_id" TYPE text`); - await queryRunner.query(`ALTER TABLE "team_members" ALTER COLUMN "role" TYPE text`); - await queryRunner.query(`ALTER TABLE "team_members" ALTER COLUMN "role" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "purchased_flags" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "public_flags" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "flags" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "user_settings" ALTER COLUMN "view_nsfw_guilds" SET DEFAULT true`); - await queryRunner.query(`ALTER TABLE "user_settings" ALTER COLUMN "friend_discovery_flags" SET DEFAULT '0'`); - await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "client_status" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "channels" ALTER COLUMN "default_thread_rate_limit_per_user" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "messages" ALTER COLUMN "avatar" TYPE text`); - await queryRunner.query(`ALTER TABLE "messages" ALTER COLUMN "username" TYPE text`); - await queryRunner.query(`ALTER TABLE "webhooks" ALTER COLUMN "source_channel_id" TYPE character varying(255)`); - await queryRunner.query(`ALTER TABLE "webhooks" ALTER COLUMN "source_channel_id" SET DEFAULT NULL`); - // await queryRunner.query(`ALTER TABLE "webhooks" ADD CONSTRAINT "fk_d64f38834fa676f6caa4786ddd6" FOREIGN KEY ("source_channel_id") REFERENCES "channels"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - } - -} \ No newline at end of file + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "applications" DROP CONSTRAINT "FK_e5bf78cdbbe9ba91062d74c5aba"`); + await queryRunner.query(`ALTER TABLE "webhooks" DROP CONSTRAINT "FK_4495b7032a33c6b8b605d030398"`); + await queryRunner.query(`ALTER TABLE "user_settings_protos" ALTER COLUMN "frecencySettings" TYPE text`); + await queryRunner.query(`ALTER TABLE "user_settings_protos" ALTER COLUMN "userSettings" TYPE text`); + await queryRunner.query(`ALTER TABLE "categories" ALTER COLUMN "icon" TYPE text`); + await queryRunner.query(`ALTER TABLE "applications" ALTER COLUMN "custom_install_url" TYPE text`); + await queryRunner.query(`ALTER TABLE "applications" ALTER COLUMN "guild_id" TYPE text`); + await queryRunner.query(`ALTER TABLE "team_members" ALTER COLUMN "role" TYPE text`); + await queryRunner.query(`ALTER TABLE "team_members" ALTER COLUMN "role" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "purchased_flags" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "public_flags" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "users" ALTER COLUMN "flags" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "user_settings" ALTER COLUMN "view_nsfw_guilds" SET DEFAULT true`); + await queryRunner.query(`ALTER TABLE "user_settings" ALTER COLUMN "friend_discovery_flags" SET DEFAULT '0'`); + await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "client_status" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "channels" ALTER COLUMN "default_thread_rate_limit_per_user" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "messages" ALTER COLUMN "avatar" TYPE text`); + await queryRunner.query(`ALTER TABLE "messages" ALTER COLUMN "username" TYPE text`); + await queryRunner.query(`ALTER TABLE "webhooks" ALTER COLUMN "source_channel_id" TYPE character varying(255)`); + await queryRunner.query(`ALTER TABLE "webhooks" ALTER COLUMN "source_channel_id" SET DEFAULT NULL`); + // await queryRunner.query(`ALTER TABLE "webhooks" ADD CONSTRAINT "fk_d64f38834fa676f6caa4786ddd6" FOREIGN KEY ("source_channel_id") REFERENCES "channels"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); + } +} diff --git a/src/util/migration/postgres/1765143034407-DontIpBanBanner.ts b/src/util/migration/postgres/1765143034407-DontIpBanBanner.ts index 6e8089e..2207e9c 100644 --- a/src/util/migration/postgres/1765143034407-DontIpBanBanner.ts +++ b/src/util/migration/postgres/1765143034407-DontIpBanBanner.ts @@ -1,16 +1,15 @@ import { MigrationInterface, QueryRunner } from "typeorm"; export class DontIpBanBanner1765143034407 implements MigrationInterface { - name = 'DontIpBanBanner1765143034407' + name = "DontIpBanBanner1765143034407"; - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "bans" ALTER COLUMN "ip" DROP NOT NULL`); + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "bans" ALTER COLUMN "ip" DROP NOT NULL`); await queryRunner.query(`UPDATE "bans" SET "ip" = NULL`); - } + } - public async down(queryRunner: QueryRunner): Promise { + public async down(queryRunner: QueryRunner): Promise { await queryRunner.query(`UPDATE "bans" SET "ip" = '0.0.0.0' WHERE "ip" IS NULL`); - await queryRunner.query(`ALTER TABLE "bans" ALTER COLUMN "ip" SET NOT NULL`); - } - + await queryRunner.query(`ALTER TABLE "bans" ALTER COLUMN "ip" SET NOT NULL`); + } } diff --git a/src/util/migration/postgres/1765578570423-InstanceBanTable.ts b/src/util/migration/postgres/1765578570423-InstanceBanTable.ts index 0baa7dc..be8cb9c 100644 --- a/src/util/migration/postgres/1765578570423-InstanceBanTable.ts +++ b/src/util/migration/postgres/1765578570423-InstanceBanTable.ts @@ -1,16 +1,19 @@ import { MigrationInterface, QueryRunner } from "typeorm"; export class InstanceBanTable1765578570423 implements MigrationInterface { - name = 'InstanceBanTable1765578570423' + name = "InstanceBanTable1765578570423"; - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE "instance_bans" ("id" character varying NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "reason" character varying NOT NULL, "user_id" character varying, "fingerprint" character varying, "ip_address" character varying, "is_from_other_instance_ban" boolean NOT NULL DEFAULT false, "origin_instance_ban_id" character varying, CONSTRAINT "REL_0b02d18d0d830f160c921192a3" UNIQUE ("origin_instance_ban_id"), CONSTRAINT "PK_3aa6e80a6d325601054892b1340" PRIMARY KEY ("id"))`); - await queryRunner.query(`ALTER TABLE "instance_bans" ADD CONSTRAINT "FK_0b02d18d0d830f160c921192a30" FOREIGN KEY ("origin_instance_ban_id") REFERENCES "instance_bans"("id") ON DELETE SET NULL ON UPDATE NO ACTION`); - } + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE "instance_bans" ("id" character varying NOT NULL, "created_at" TIMESTAMP NOT NULL DEFAULT now(), "reason" character varying NOT NULL, "user_id" character varying, "fingerprint" character varying, "ip_address" character varying, "is_from_other_instance_ban" boolean NOT NULL DEFAULT false, "origin_instance_ban_id" character varying, CONSTRAINT "REL_0b02d18d0d830f160c921192a3" UNIQUE ("origin_instance_ban_id"), CONSTRAINT "PK_3aa6e80a6d325601054892b1340" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `ALTER TABLE "instance_bans" ADD CONSTRAINT "FK_0b02d18d0d830f160c921192a30" FOREIGN KEY ("origin_instance_ban_id") REFERENCES "instance_bans"("id") ON DELETE SET NULL ON UPDATE NO ACTION`, + ); + } - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "instance_bans" DROP CONSTRAINT "FK_0b02d18d0d830f160c921192a30"`); - await queryRunner.query(`DROP TABLE "instance_bans"`); - } - + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "instance_bans" DROP CONSTRAINT "FK_0b02d18d0d830f160c921192a30"`); + await queryRunner.query(`DROP TABLE "instance_bans"`); + } } diff --git a/src/util/migration/postgres/1765587835846-InstanceBanAllowlist.ts b/src/util/migration/postgres/1765587835846-InstanceBanAllowlist.ts index fd8da01..8c907aa 100644 --- a/src/util/migration/postgres/1765587835846-InstanceBanAllowlist.ts +++ b/src/util/migration/postgres/1765587835846-InstanceBanAllowlist.ts @@ -1,14 +1,13 @@ import { MigrationInterface, QueryRunner } from "typeorm"; export class InstanceBanAllowlist1765587835846 implements MigrationInterface { - name = 'InstanceBanAllowlist1765587835846' + name = "InstanceBanAllowlist1765587835846"; - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "instance_bans" ADD "is_allowlisted" boolean NOT NULL DEFAULT false`); - } + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "instance_bans" ADD "is_allowlisted" boolean NOT NULL DEFAULT false`); + } - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "instance_bans" DROP COLUMN "is_allowlisted"`); - } - + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "instance_bans" DROP COLUMN "is_allowlisted"`); + } } diff --git a/src/util/migration/postgres/1765665440000-DropDefaultIPDataKey.ts b/src/util/migration/postgres/1765665440000-DropDefaultIPDataKey.ts index ad1b736..ea887b1 100644 --- a/src/util/migration/postgres/1765665440000-DropDefaultIPDataKey.ts +++ b/src/util/migration/postgres/1765665440000-DropDefaultIPDataKey.ts @@ -1,14 +1,17 @@ import { MigrationInterface, QueryRunner } from "typeorm"; export class DropDefaultIPDataKey1765665440000 implements MigrationInterface { - name = 'DropDefaultIPDataKey1765665440000' + name = "DropDefaultIPDataKey1765665440000"; - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`UPDATE "config" SET "value" = NULL WHERE "key" = 'security_ipdataApiKey' AND "value" = '"eca677b284b3bac29eb72f5e496aa9047f26543605efe99ff2ce35c9"'`); - } + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `UPDATE "config" SET "value" = NULL WHERE "key" = 'security_ipdataApiKey' AND "value" = '"eca677b284b3bac29eb72f5e496aa9047f26543605efe99ff2ce35c9"'`, + ); + } - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`UPDATE "config" SET "value" = '"eca677b284b3bac29eb72f5e496aa9047f26543605efe99ff2ce35c9"' WHERE "key" = 'security_ipdataApiKey' AND "value" IS NULL`); - } - + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `UPDATE "config" SET "value" = '"eca677b284b3bac29eb72f5e496aa9047f26543605efe99ff2ce35c9"' WHERE "key" = 'security_ipdataApiKey' AND "value" IS NULL`, + ); + } } diff --git a/src/util/migration/postgres/1765863159930-ExtendedSessionInfo.ts b/src/util/migration/postgres/1765863159930-ExtendedSessionInfo.ts index 0ed0998..c320ed7 100644 --- a/src/util/migration/postgres/1765863159930-ExtendedSessionInfo.ts +++ b/src/util/migration/postgres/1765863159930-ExtendedSessionInfo.ts @@ -1,38 +1,41 @@ import { MigrationInterface, QueryRunner } from "typeorm"; export class ExtendedSessionInfo1765863159930 implements MigrationInterface { - name = 'ExtendedSessionInfo1765863159930' + name = "ExtendedSessionInfo1765863159930"; - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "sessions" DROP CONSTRAINT "PK_3238ef96f18b355b671619111bc"`); - await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "id"`); - await queryRunner.query(`ALTER TABLE "sessions" ADD "is_admin_session" boolean NOT NULL DEFAULT false`); - await queryRunner.query(`ALTER TABLE "sessions" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); - await queryRunner.query(`ALTER TABLE "sessions" ADD "last_seen" TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00'`); - await queryRunner.query(`ALTER TABLE "sessions" ADD "last_seen_ip" character varying NOT NULL DEFAULT '127.0.0.1'`); - await queryRunner.query(`ALTER TABLE "sessions" ADD "last_seen_location" character varying`); - await queryRunner.query(`ALTER TABLE "webhooks" ALTER COLUMN "source_channel_id" DROP DEFAULT`); - await queryRunner.query(`ALTER TABLE "sessions" DROP CONSTRAINT "FK_085d540d9f418cfbdc7bd55bb19"`); - await queryRunner.query(`ALTER TABLE "sessions" ADD CONSTRAINT "PK_9340188c93349808f10d1db74a8" PRIMARY KEY ("session_id")`); - await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "user_id" SET NOT NULL`); - await queryRunner.query(`CREATE INDEX "IDX_085d540d9f418cfbdc7bd55bb1" ON "sessions" ("user_id") `); - await queryRunner.query(`ALTER TABLE "sessions" ADD CONSTRAINT "FK_085d540d9f418cfbdc7bd55bb19" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - } + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "sessions" DROP CONSTRAINT "PK_3238ef96f18b355b671619111bc"`); + await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "id"`); + await queryRunner.query(`ALTER TABLE "sessions" ADD "is_admin_session" boolean NOT NULL DEFAULT false`); + await queryRunner.query(`ALTER TABLE "sessions" ADD "created_at" TIMESTAMP NOT NULL DEFAULT now()`); + await queryRunner.query(`ALTER TABLE "sessions" ADD "last_seen" TIMESTAMP NOT NULL DEFAULT '1970-01-01 00:00:00'`); + await queryRunner.query(`ALTER TABLE "sessions" ADD "last_seen_ip" character varying NOT NULL DEFAULT '127.0.0.1'`); + await queryRunner.query(`ALTER TABLE "sessions" ADD "last_seen_location" character varying`); + await queryRunner.query(`ALTER TABLE "webhooks" ALTER COLUMN "source_channel_id" DROP DEFAULT`); + await queryRunner.query(`ALTER TABLE "sessions" DROP CONSTRAINT "FK_085d540d9f418cfbdc7bd55bb19"`); + await queryRunner.query(`ALTER TABLE "sessions" ADD CONSTRAINT "PK_9340188c93349808f10d1db74a8" PRIMARY KEY ("session_id")`); + await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "user_id" SET NOT NULL`); + await queryRunner.query(`CREATE INDEX "IDX_085d540d9f418cfbdc7bd55bb1" ON "sessions" ("user_id") `); + await queryRunner.query( + `ALTER TABLE "sessions" ADD CONSTRAINT "FK_085d540d9f418cfbdc7bd55bb19" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + } - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "sessions" DROP CONSTRAINT "FK_085d540d9f418cfbdc7bd55bb19"`); - await queryRunner.query(`ALTER TABLE "webhooks" DROP CONSTRAINT "FK_4495b7032a33c6b8b605d030398"`); - await queryRunner.query(`DROP INDEX "public"."IDX_085d540d9f418cfbdc7bd55bb1"`); - await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "user_id" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "sessions" DROP CONSTRAINT "PK_9340188c93349808f10d1db74a8"`); - await queryRunner.query(`ALTER TABLE "sessions" ADD CONSTRAINT "FK_085d540d9f418cfbdc7bd55bb19" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "last_seen_location"`); - await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "last_seen_ip"`); - await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "last_seen"`); - await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "created_at"`); - await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "is_admin_session"`); - await queryRunner.query(`ALTER TABLE "sessions" ADD "id" character varying NOT NULL`); - await queryRunner.query(`ALTER TABLE "sessions" ADD CONSTRAINT "PK_3238ef96f18b355b671619111bc" PRIMARY KEY ("id")`); - } - + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "sessions" DROP CONSTRAINT "FK_085d540d9f418cfbdc7bd55bb19"`); + await queryRunner.query(`ALTER TABLE "webhooks" DROP CONSTRAINT "FK_4495b7032a33c6b8b605d030398"`); + await queryRunner.query(`DROP INDEX "public"."IDX_085d540d9f418cfbdc7bd55bb1"`); + await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "user_id" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "sessions" DROP CONSTRAINT "PK_9340188c93349808f10d1db74a8"`); + await queryRunner.query( + `ALTER TABLE "sessions" ADD CONSTRAINT "FK_085d540d9f418cfbdc7bd55bb19" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "last_seen_location"`); + await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "last_seen_ip"`); + await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "last_seen"`); + await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "created_at"`); + await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "is_admin_session"`); + await queryRunner.query(`ALTER TABLE "sessions" ADD "id" character varying NOT NULL`); + await queryRunner.query(`ALTER TABLE "sessions" ADD CONSTRAINT "PK_3238ef96f18b355b671619111bc" PRIMARY KEY ("id")`); + } } diff --git a/src/util/migration/postgres/1765932247127-UpdateSessionInfo.ts b/src/util/migration/postgres/1765932247127-UpdateSessionInfo.ts index d18dfbd..3da3498 100644 --- a/src/util/migration/postgres/1765932247127-UpdateSessionInfo.ts +++ b/src/util/migration/postgres/1765932247127-UpdateSessionInfo.ts @@ -1,24 +1,23 @@ import { MigrationInterface, QueryRunner } from "typeorm"; export class UpdateSessionInfo1765932247127 implements MigrationInterface { - name = 'UpdateSessionInfo1765932247127' + name = "UpdateSessionInfo1765932247127"; - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "sessions" ADD "last_seen_location_info" text`); - await queryRunner.query(`ALTER TABLE "sessions" ADD "session_nickname" character varying`); - await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "last_seen" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "last_seen" DROP DEFAULT`); - await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "last_seen_ip" DROP NOT NULL`); - await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "last_seen_ip" DROP DEFAULT`); - } + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "sessions" ADD "last_seen_location_info" text`); + await queryRunner.query(`ALTER TABLE "sessions" ADD "session_nickname" character varying`); + await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "last_seen" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "last_seen" DROP DEFAULT`); + await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "last_seen_ip" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "last_seen_ip" DROP DEFAULT`); + } - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "last_seen_ip" SET DEFAULT '127.0.0.1'`); - await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "last_seen_ip" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "last_seen" SET DEFAULT '1970-01-01 00:00:00'`); - await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "last_seen" SET NOT NULL`); - await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "session_nickname"`); - await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "last_seen_location_info"`); - } - + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "last_seen_ip" SET DEFAULT '127.0.0.1'`); + await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "last_seen_ip" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "last_seen" SET DEFAULT '1970-01-01 00:00:00'`); + await queryRunner.query(`ALTER TABLE "sessions" ALTER COLUMN "last_seen" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "session_nickname"`); + await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "last_seen_location_info"`); + } }