From 3ce284538ced2852bd8aa48acda8f7fad3d4554a Mon Sep 17 00:00:00 2001 From: gauthier-th Date: Sat, 21 Dec 2024 14:12:54 +0100 Subject: [PATCH] fix: fix PostgreSQL migrations and TelegramMessageThreadId migration --- .../1705599190375-InitialMigration.ts | 304 ------------------ .../postgres/1730770837441-AddBlacklist.ts | 32 -- ...71530757-AddUserSettingsStreamingRegion.ts | 89 ----- .../1734786061496-InitialMigration.ts | 195 +++++++++++ ...734786596045-AddTelegramMessageThreadId.ts | 19 ++ ...734287582736-AddTelegramMessageThreadId.ts | 0 6 files changed, 214 insertions(+), 425 deletions(-) delete mode 100644 server/migration/postgres/1705599190375-InitialMigration.ts delete mode 100644 server/migration/postgres/1730770837441-AddBlacklist.ts delete mode 100644 server/migration/postgres/1730771530757-AddUserSettingsStreamingRegion.ts create mode 100644 server/migration/postgres/1734786061496-InitialMigration.ts create mode 100644 server/migration/postgres/1734786596045-AddTelegramMessageThreadId.ts rename server/migration/{ => sqlite}/1734287582736-AddTelegramMessageThreadId.ts (100%) diff --git a/server/migration/postgres/1705599190375-InitialMigration.ts b/server/migration/postgres/1705599190375-InitialMigration.ts deleted file mode 100644 index 20e349c5a..000000000 --- a/server/migration/postgres/1705599190375-InitialMigration.ts +++ /dev/null @@ -1,304 +0,0 @@ -import type { MigrationInterface, QueryRunner } from 'typeorm'; - -export class InitialMigration1705599190375 implements MigrationInterface { - name = 'InitialMigration1705599190375'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `create table if not exists session - ( - "expiredAt" bigint, - id text, - json text - );` - ); - await queryRunner.query( - `create index if not exists "idx_194703_IDX_28c5d1d16da7908c97c9bc2f74" - on session ("expiredAt");` - ); - await queryRunner.query( - `create unique index if not exists idx_194703_sqlite_autoindex_session_1 - on session (id);` - ); - await queryRunner.query( - `create table if not exists media - ( - id serial, - "mediaType" text, - "tmdbId" int, - "tvdbId" int, - "imdbId" text, - status int default '1'::int, - status4k int default '1'::int, - "createdAt" timestamp with time zone default CURRENT_TIMESTAMP, - "updatedAt" timestamp with time zone default CURRENT_TIMESTAMP, - "lastSeasonChange" timestamp with time zone default CURRENT_TIMESTAMP, - "mediaAddedAt" timestamp with time zone, - "serviceId" int, - "serviceId4k" int, - "externalServiceId" int, - "externalServiceId4k" int, - "externalServiceSlug" text, - "externalServiceSlug4k" text, - "ratingKey" text, - "ratingKey4k" text, - "jellyfinMediaId" text, - "jellyfinMediaId4k" text, - constraint idx_194722_media_pkey - primary key (id) - );` - ); - await queryRunner.query( - `create table if not exists season - ( - id serial, - "seasonNumber" int, - status int default '1'::int, - "createdAt" timestamp with time zone default CURRENT_TIMESTAMP, - "updatedAt" timestamp with time zone default CURRENT_TIMESTAMP, - "mediaId" int not null, - status4k int default '1'::int, - constraint idx_194715_season_pkey - primary key (id), - foreign key ("mediaId") references media - on delete cascade - );` - ); - await queryRunner.query( - `create index if not exists "idx_194722_IDX_7ff2d11f6a83cb52386eaebe74" - on media ("imdbId");` - ); - await queryRunner.query( - `create index if not exists "idx_194722_IDX_41a289eb1fa489c1bc6f38d9c3" - on media ("tvdbId");` - ); - await queryRunner.query( - `create index if not exists "idx_194722_IDX_7157aad07c73f6a6ae3bbd5ef5" - on media ("tmdbId");` - ); - await queryRunner.query( - `create unique index if not exists idx_194722_sqlite_autoindex_media_1 - on media ("tvdbId");` - ); - await queryRunner.query( - `create table if not exists "user" - ( - id serial, - email text, - username text, - "plexId" int, - "plexToken" text, - permissions int default '0'::int, - avatar text, - "createdAt" timestamp with time zone default CURRENT_TIMESTAMP, - "updatedAt" timestamp with time zone default CURRENT_TIMESTAMP, - password text, - "userType" int default '1'::int, - "plexUsername" text, - "resetPasswordGuid" text, - "recoveryLinkExpirationDate" date, - "movieQuotaLimit" int, - "movieQuotaDays" int, - "tvQuotaLimit" int, - "tvQuotaDays" int, - "jellyfinUsername" text, - "jellyfinAuthToken" text, - "jellyfinUserId" text, - "jellyfinDeviceId" text, - constraint idx_194731_user_pkey - primary key (id) - );` - ); - await queryRunner.query( - `create unique index if not exists idx_194731_sqlite_autoindex_user_1 - on "user" (email);` - ); - await queryRunner.query( - `create table if not exists user_push_subscription - ( - id serial, - endpoint text, - p256dh text, - auth text, - "userId" int, - constraint idx_194740_user_push_subscription_pkey - primary key (id), - foreign key ("userId") references "user" - on delete cascade - );` - ); - await queryRunner.query( - `create unique index if not exists idx_194740_sqlite_autoindex_user_push_subscription_1 - on user_push_subscription (auth);` - ); - await queryRunner.query( - `create table if not exists issue - ( - id serial, - "issueType" int, - status int default '1'::int, - "problemSeason" int default '0'::int, - "problemEpisode" int default '0'::int, - "createdAt" timestamp with time zone default CURRENT_TIMESTAMP, - "updatedAt" timestamp with time zone default CURRENT_TIMESTAMP, - "mediaId" int not null, - "createdById" int, - "modifiedById" int, - constraint idx_194747_issue_pkey - primary key (id), - foreign key ("modifiedById") references "user" - on delete cascade, - foreign key ("createdById") references "user" - on delete cascade, - foreign key ("mediaId") references media - on delete cascade - );` - ); - await queryRunner.query( - `create table if not exists issue_comment - ( - id serial, - message text, - "createdAt" timestamp with time zone default CURRENT_TIMESTAMP, - "updatedAt" timestamp with time zone default CURRENT_TIMESTAMP, - "userId" int, - "issueId" int, - constraint idx_194755_issue_comment_pkey - primary key (id), - foreign key ("issueId") references issue - on delete cascade, - foreign key ("userId") references "user" - on delete cascade - );` - ); - await queryRunner.query( - `create table if not exists user_settings - ( - id serial, - "notificationTypes" text, - "discordId" text, - "userId" int, - region text, - "originalLanguage" text, - "telegramChatId" text, - "telegramSendSilently" boolean, - "pgpKey" text, - locale text default ''::text, - "pushbulletAccessToken" text, - "pushoverApplicationToken" text, - "pushoverUserKey" text, - "watchlistSyncMovies" boolean, - "watchlistSyncTv" boolean, - "pushoverSound" varchar, - constraint idx_194762_user_settings_pkey - primary key (id), - foreign key ("userId") references "user" - on delete cascade - );` - ); - await queryRunner.query( - `create unique index if not exists idx_194762_sqlite_autoindex_user_settings_1 - on user_settings ("userId");` - ); - await queryRunner.query( - `create table if not exists media_request - ( - id serial, - status int, - "createdAt" timestamp with time zone default CURRENT_TIMESTAMP, - "updatedAt" timestamp with time zone default CURRENT_TIMESTAMP, - type text, - "mediaId" int not null, - "requestedById" int, - "modifiedById" int, - is4k boolean default false, - "serverId" int, - "profileId" int, - "rootFolder" text, - "languageProfileId" int, - tags text, - "isAutoRequest" boolean default false, - constraint idx_194770_media_request_pkey - primary key (id), - foreign key ("modifiedById") references "user" - on delete set null, - foreign key ("requestedById") references "user" - on delete cascade, - foreign key ("mediaId") references media - on delete cascade - );` - ); - await queryRunner.query( - `create table if not exists season_request - ( - id serial NOT NULL, - "seasonNumber" int, - status int default '1'::int, - "createdAt" timestamp with time zone default now(), - "updatedAt" timestamp with time zone default now(), - "requestId" int, - constraint idx_194709_season_request_pkey - primary key (id), - foreign key ("requestId") references media_request - on delete cascade - );` - ); - await queryRunner.query( - `create table if not exists discover_slider - ( - id serial, - type integer, - "order" integer, - "isBuiltIn" boolean default false, - enabled boolean default true, - title text, - data text, - "createdAt" timestamp with time zone default CURRENT_TIMESTAMP, - "updatedAt" timestamp with time zone default CURRENT_TIMESTAMP, - constraint idx_194779_discover_slider_pkey - primary key (id) - );` - ); - await queryRunner.query( - `create table if not exists watchlist - ( - id serial, - "ratingKey" text, - "mediaType" text, - title text, - "tmdbId" int, - "createdAt" timestamp with time zone default CURRENT_TIMESTAMP, - "updatedAt" timestamp with time zone default CURRENT_TIMESTAMP, - "requestedById" int, - "mediaId" int not null, - constraint idx_194788_watchlist_pkey - primary key (id) - );` - ); - await queryRunner.query( - `create index if not exists "idx_194788_IDX_939f205946256cc0d2a1ac51a8" - on watchlist ("tmdbId");` - ); - await queryRunner.query( - `create unique index if not exists idx_194788_sqlite_autoindex_watchlist_1 - on watchlist ("tmdbId", "requestedById");` - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`drop table if exists session cascade`); - await queryRunner.query(`drop table if exists season_request cascade`); - await queryRunner.query(`drop table if exists season cascade`); - await queryRunner.query( - `drop table if exists user_push_subscription cascade` - ); - await queryRunner.query(`drop table if exists issue_comment cascade`); - await queryRunner.query(`drop table if exists issue cascade`); - await queryRunner.query(`drop table if exists user_settings cascade`); - await queryRunner.query(`drop table if exists media_request cascade`); - await queryRunner.query(`drop table if exists media cascade`); - await queryRunner.query(`drop table if exists "user" cascade`); - await queryRunner.query(`drop table if exists discover_slider cascade`); - await queryRunner.query(`drop table if exists watchlist cascade`); - } -} diff --git a/server/migration/postgres/1730770837441-AddBlacklist.ts b/server/migration/postgres/1730770837441-AddBlacklist.ts deleted file mode 100644 index 40fcb9048..000000000 --- a/server/migration/postgres/1730770837441-AddBlacklist.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { MigrationInterface, QueryRunner } from 'typeorm'; - -export class AddBlacklist1730770837441 implements MigrationInterface { - name = 'AddBlacklist1730770837441'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TABLE "blacklist" - ( - "id" SERIAL PRIMARY KEY, - "mediaType" VARCHAR NOT NULL, - "title" VARCHAR, - "tmdbId" INTEGER NOT NULL, - "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), - "userId" INTEGER, - "mediaId" INTEGER, - CONSTRAINT "UQ_6bbafa28411e6046421991ea21c" UNIQUE ("tmdbId", "userId") - )` - ); - - await queryRunner.query( - `CREATE INDEX "IDX_6bbafa28411e6046421991ea21" ON "blacklist" ("tmdbId")` - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `DROP INDEX IF EXISTS "IDX_6bbafa28411e6046421991ea21"` - ); - await queryRunner.query(`DROP TABLE IF EXISTS "blacklist"`); - } -} diff --git a/server/migration/postgres/1730771530757-AddUserSettingsStreamingRegion.ts b/server/migration/postgres/1730771530757-AddUserSettingsStreamingRegion.ts deleted file mode 100644 index 9a98228b3..000000000 --- a/server/migration/postgres/1730771530757-AddUserSettingsStreamingRegion.ts +++ /dev/null @@ -1,89 +0,0 @@ -import type { MigrationInterface, QueryRunner } from 'typeorm'; - -export class AddUserSettingsStreamingRegion1727907530757 - implements MigrationInterface -{ - name = 'AddUserSettingsStreamingRegion1727907530757'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TABLE "temporary_user_settings" ( - "id" SERIAL PRIMARY KEY, - "notificationTypes" text, - "discordId" varchar, - "userId" integer, - "originalLanguage" varchar, - "telegramChatId" varchar, - "telegramSendSilently" boolean, - "pgpKey" varchar, - "locale" varchar NOT NULL DEFAULT '', - "pushbulletAccessToken" varchar, - "pushoverApplicationToken" varchar, - "pushoverUserKey" varchar, - "watchlistSyncMovies" boolean, - "watchlistSyncTv" boolean, - "pushoverSound" varchar, - CONSTRAINT "UQ_986a2b6d3c05eb4091bb8066f78" UNIQUE ("userId"), - CONSTRAINT "FK_986a2b6d3c05eb4091bb8066f78" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION - )` - ); - await queryRunner.query( - `INSERT INTO "temporary_user_settings"( - "id", "notificationTypes", "discordId", "userId", "originalLanguage", "telegramChatId", "telegramSendSilently", "pgpKey", "locale", "pushbulletAccessToken", "pushoverApplicationToken", "pushoverUserKey", "watchlistSyncMovies", "watchlistSyncTv", "pushoverSound" - ) SELECT - "id", "notificationTypes", "discordId", "userId", "originalLanguage", "telegramChatId", "telegramSendSilently", "pgpKey", "locale", "pushbulletAccessToken", "pushoverApplicationToken", "pushoverUserKey", "watchlistSyncMovies", "watchlistSyncTv", "pushoverSound" - FROM "user_settings"` - ); - await queryRunner.query(`DROP TABLE "user_settings"`); - await queryRunner.query( - `ALTER TABLE "temporary_user_settings" RENAME TO "user_settings"` - ); - await queryRunner.query( - `ALTER TABLE "user_settings" ADD COLUMN "discoverRegion" varchar` - ); - await queryRunner.query( - `ALTER TABLE "user_settings" ADD COLUMN "streamingRegion" varchar` - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "user_settings" DROP COLUMN "streamingRegion"` - ); - await queryRunner.query( - `ALTER TABLE "user_settings" DROP COLUMN "discoverRegion"` - ); - await queryRunner.query( - `ALTER TABLE "user_settings" RENAME TO "temporary_user_settings"` - ); - await queryRunner.query( - `CREATE TABLE "user_settings" ( - "id" SERIAL PRIMARY KEY, - "notificationTypes" text, - "discordId" varchar, - "userId" integer, - "originalLanguage" varchar, - "telegramChatId" varchar, - "telegramSendSilently" boolean, - "pgpKey" varchar, - "locale" varchar NOT NULL DEFAULT '', - "pushbulletAccessToken" varchar, - "pushoverApplicationToken" varchar, - "pushoverUserKey" varchar, - "watchlistSyncMovies" boolean, - "watchlistSyncTv" boolean, - "pushoverSound" varchar, - CONSTRAINT "UQ_986a2b6d3c05eb4091bb8066f78" UNIQUE ("userId"), - CONSTRAINT "FK_986a2b6d3c05eb4091bb8066f78" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION - )` - ); - await queryRunner.query( - `INSERT INTO "user_settings"( - "id", "notificationTypes", "discordId", "userId", "originalLanguage", "telegramChatId", "telegramSendSilently", "pgpKey", "locale", "pushbulletAccessToken", "pushoverApplicationToken", "pushoverUserKey", "watchlistSyncMovies", "watchlistSyncTv", "pushoverSound" - ) SELECT - "id", "notificationTypes", "discordId", "userId", "originalLanguage", "telegramChatId", "telegramSendSilently", "pgpKey", "locale", "pushbulletAccessToken", "pushoverApplicationToken", "pushoverUserKey", "watchlistSyncMovies", "watchlistSyncTv", "pushoverSound" - FROM "temporary_user_settings"` - ); - await queryRunner.query(`DROP TABLE "temporary_user_settings"`); - } -} diff --git a/server/migration/postgres/1734786061496-InitialMigration.ts b/server/migration/postgres/1734786061496-InitialMigration.ts new file mode 100644 index 000000000..592c56fb6 --- /dev/null +++ b/server/migration/postgres/1734786061496-InitialMigration.ts @@ -0,0 +1,195 @@ +import type { MigrationInterface, QueryRunner } from 'typeorm'; + +export class InitialMigration1734786061496 implements MigrationInterface { + name = 'InitialMigration1734786061496'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TABLE "blacklist" ("id" SERIAL NOT NULL, "mediaType" character varying NOT NULL, "title" character varying, "tmdbId" integer NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "userId" integer, "mediaId" integer, CONSTRAINT "UQ_6bbafa28411e6046421991ea21c" UNIQUE ("tmdbId"), CONSTRAINT "REL_62b7ade94540f9f8d8bede54b9" UNIQUE ("mediaId"), CONSTRAINT "PK_04dc42a96bf0914cda31b579702" PRIMARY KEY ("id"))` + ); + await queryRunner.query( + `CREATE INDEX "IDX_6bbafa28411e6046421991ea21" ON "blacklist" ("tmdbId") ` + ); + await queryRunner.query( + `CREATE TABLE "season_request" ("id" SERIAL NOT NULL, "seasonNumber" integer NOT NULL, "status" integer NOT NULL DEFAULT '1', "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "requestId" integer, CONSTRAINT "PK_4811e502081543bf620f1fa4328" PRIMARY KEY ("id"))` + ); + await queryRunner.query( + `CREATE TABLE "media_request" ("id" SERIAL NOT NULL, "status" integer NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "type" character varying NOT NULL, "is4k" boolean NOT NULL DEFAULT false, "serverId" integer, "profileId" integer, "rootFolder" character varying, "languageProfileId" integer, "tags" text, "isAutoRequest" boolean NOT NULL DEFAULT false, "mediaId" integer NOT NULL, "requestedById" integer, "modifiedById" integer, CONSTRAINT "PK_f8334500e8e12db87536558c66c" PRIMARY KEY ("id"))` + ); + await queryRunner.query( + `CREATE TABLE "season" ("id" SERIAL NOT NULL, "seasonNumber" integer NOT NULL, "status" integer NOT NULL DEFAULT '1', "status4k" integer NOT NULL DEFAULT '1', "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "mediaId" integer NOT NULL, CONSTRAINT "PK_8ac0d081dbdb7ab02d166bcda9f" PRIMARY KEY ("id"))` + ); + await queryRunner.query( + `CREATE TABLE "media" ("id" SERIAL NOT NULL, "mediaType" character varying NOT NULL, "tmdbId" integer NOT NULL, "tvdbId" integer, "imdbId" character varying, "status" integer NOT NULL DEFAULT '1', "status4k" integer NOT NULL DEFAULT '1', "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "lastSeasonChange" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "mediaAddedAt" TIMESTAMP WITH TIME ZONE DEFAULT now(), "serviceId" integer, "serviceId4k" integer, "externalServiceId" integer, "externalServiceId4k" integer, "externalServiceSlug" character varying, "externalServiceSlug4k" character varying, "ratingKey" character varying, "ratingKey4k" character varying, "jellyfinMediaId" character varying, "jellyfinMediaId4k" character varying, CONSTRAINT "UQ_41a289eb1fa489c1bc6f38d9c3c" UNIQUE ("tvdbId"), CONSTRAINT "PK_f4e0fcac36e050de337b670d8bd" PRIMARY KEY ("id"))` + ); + await queryRunner.query( + `CREATE INDEX "IDX_7157aad07c73f6a6ae3bbd5ef5" ON "media" ("tmdbId") ` + ); + await queryRunner.query( + `CREATE INDEX "IDX_41a289eb1fa489c1bc6f38d9c3" ON "media" ("tvdbId") ` + ); + await queryRunner.query( + `CREATE INDEX "IDX_7ff2d11f6a83cb52386eaebe74" ON "media" ("imdbId") ` + ); + await queryRunner.query( + `CREATE TABLE "watchlist" ("id" SERIAL NOT NULL, "ratingKey" character varying NOT NULL, "mediaType" character varying NOT NULL, "title" character varying NOT NULL, "tmdbId" integer NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "requestedById" integer, "mediaId" integer NOT NULL, CONSTRAINT "UNIQUE_USER_DB" UNIQUE ("tmdbId", "requestedById"), CONSTRAINT "PK_0c8c0dbcc8d379117138e71ad5b" PRIMARY KEY ("id"))` + ); + await queryRunner.query( + `CREATE INDEX "IDX_939f205946256cc0d2a1ac51a8" ON "watchlist" ("tmdbId") ` + ); + await queryRunner.query( + `CREATE TABLE "user_push_subscription" ("id" SERIAL NOT NULL, "endpoint" character varying NOT NULL, "p256dh" character varying NOT NULL, "auth" character varying NOT NULL, "userId" integer, CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "PK_397020e7be9a4086cc798e0bb63" PRIMARY KEY ("id"))` + ); + await queryRunner.query( + `CREATE TABLE "user_settings" ("id" SERIAL NOT NULL, "locale" character varying NOT NULL DEFAULT '', "discoverRegion" character varying, "streamingRegion" character varying, "originalLanguage" character varying, "pgpKey" character varying, "discordId" character varying, "pushbulletAccessToken" character varying, "pushoverApplicationToken" character varying, "pushoverUserKey" character varying, "pushoverSound" character varying, "telegramChatId" character varying, "telegramSendSilently" boolean, "watchlistSyncMovies" boolean, "watchlistSyncTv" boolean, "notificationTypes" text, "userId" integer, CONSTRAINT "REL_986a2b6d3c05eb4091bb8066f7" UNIQUE ("userId"), CONSTRAINT "PK_00f004f5922a0744d174530d639" PRIMARY KEY ("id"))` + ); + await queryRunner.query( + `CREATE TABLE "user" ("id" SERIAL NOT NULL, "email" character varying NOT NULL, "plexUsername" character varying, "jellyfinUsername" character varying, "username" character varying, "password" character varying, "resetPasswordGuid" character varying, "recoveryLinkExpirationDate" date, "userType" integer NOT NULL DEFAULT '1', "plexId" integer, "jellyfinUserId" character varying, "jellyfinDeviceId" character varying, "jellyfinAuthToken" character varying, "plexToken" character varying, "permissions" integer NOT NULL DEFAULT '0', "avatar" character varying NOT NULL, "movieQuotaLimit" integer, "movieQuotaDays" integer, "tvQuotaLimit" integer, "tvQuotaDays" integer, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UQ_e12875dfb3b1d92d7d7c5377e22" UNIQUE ("email"), CONSTRAINT "PK_cace4a159ff9f2512dd42373760" PRIMARY KEY ("id"))` + ); + await queryRunner.query( + `CREATE TABLE "issue_comment" ("id" SERIAL NOT NULL, "message" text NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "userId" integer, "issueId" integer, CONSTRAINT "PK_2ad05784e2ae661fa409e5e0248" PRIMARY KEY ("id"))` + ); + await queryRunner.query( + `CREATE TABLE "issue" ("id" SERIAL NOT NULL, "issueType" integer NOT NULL, "status" integer NOT NULL DEFAULT '1', "problemSeason" integer NOT NULL DEFAULT '0', "problemEpisode" integer NOT NULL DEFAULT '0', "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), "mediaId" integer, "createdById" integer, "modifiedById" integer, CONSTRAINT "PK_f80e086c249b9f3f3ff2fd321b7" PRIMARY KEY ("id"))` + ); + await queryRunner.query( + `CREATE TABLE "discover_slider" ("id" SERIAL NOT NULL, "type" integer NOT NULL, "order" integer NOT NULL, "isBuiltIn" boolean NOT NULL DEFAULT false, "enabled" boolean NOT NULL DEFAULT true, "title" character varying, "data" character varying, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_20a71a098d04bae448e4d51db23" PRIMARY KEY ("id"))` + ); + await queryRunner.query( + `CREATE TABLE "session" ("expiredAt" bigint NOT NULL, "id" character varying(255) NOT NULL, "json" text NOT NULL, CONSTRAINT "PK_f55da76ac1c3ac420f444d2ff11" PRIMARY KEY ("id"))` + ); + await queryRunner.query( + `CREATE INDEX "IDX_28c5d1d16da7908c97c9bc2f74" ON "session" ("expiredAt") ` + ); + await queryRunner.query( + `ALTER TABLE "blacklist" ADD CONSTRAINT "FK_53c1ab62c3e5875bc3ac474823e" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION` + ); + await queryRunner.query( + `ALTER TABLE "blacklist" ADD CONSTRAINT "FK_62b7ade94540f9f8d8bede54b99" FOREIGN KEY ("mediaId") REFERENCES "media"("id") ON DELETE CASCADE ON UPDATE NO ACTION` + ); + await queryRunner.query( + `ALTER TABLE "season_request" ADD CONSTRAINT "FK_6f14737e346d6b27d8e50d2157a" FOREIGN KEY ("requestId") REFERENCES "media_request"("id") ON DELETE CASCADE ON UPDATE NO ACTION` + ); + await queryRunner.query( + `ALTER TABLE "media_request" ADD CONSTRAINT "FK_a1aa713f41c99e9d10c48da75a0" FOREIGN KEY ("mediaId") REFERENCES "media"("id") ON DELETE CASCADE ON UPDATE NO ACTION` + ); + await queryRunner.query( + `ALTER TABLE "media_request" ADD CONSTRAINT "FK_6997bee94720f1ecb7f31137095" FOREIGN KEY ("requestedById") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION` + ); + await queryRunner.query( + `ALTER TABLE "media_request" ADD CONSTRAINT "FK_f4fc4efa14c3ba2b29c4525fa15" FOREIGN KEY ("modifiedById") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE NO ACTION` + ); + await queryRunner.query( + `ALTER TABLE "season" ADD CONSTRAINT "FK_087099b39600be695591da9a49c" FOREIGN KEY ("mediaId") REFERENCES "media"("id") ON DELETE CASCADE ON UPDATE NO ACTION` + ); + await queryRunner.query( + `ALTER TABLE "watchlist" ADD CONSTRAINT "FK_ae34e6b153a90672eb9dc4857d7" FOREIGN KEY ("requestedById") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION` + ); + await queryRunner.query( + `ALTER TABLE "watchlist" ADD CONSTRAINT "FK_6641da8d831b93dfcb429f8b8bc" FOREIGN KEY ("mediaId") REFERENCES "media"("id") ON DELETE CASCADE ON UPDATE NO ACTION` + ); + await queryRunner.query( + `ALTER TABLE "user_push_subscription" ADD CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION` + ); + await queryRunner.query( + `ALTER TABLE "user_settings" ADD CONSTRAINT "FK_986a2b6d3c05eb4091bb8066f78" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION` + ); + await queryRunner.query( + `ALTER TABLE "issue_comment" ADD CONSTRAINT "FK_707b033c2d0653f75213614789d" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION` + ); + await queryRunner.query( + `ALTER TABLE "issue_comment" ADD CONSTRAINT "FK_180710fead1c94ca499c57a7d42" FOREIGN KEY ("issueId") REFERENCES "issue"("id") ON DELETE CASCADE ON UPDATE NO ACTION` + ); + await queryRunner.query( + `ALTER TABLE "issue" ADD CONSTRAINT "FK_276e20d053f3cff1645803c95d8" FOREIGN KEY ("mediaId") REFERENCES "media"("id") ON DELETE CASCADE ON UPDATE NO ACTION` + ); + await queryRunner.query( + `ALTER TABLE "issue" ADD CONSTRAINT "FK_10b17b49d1ee77e7184216001e0" FOREIGN KEY ("createdById") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION` + ); + await queryRunner.query( + `ALTER TABLE "issue" ADD CONSTRAINT "FK_da88a1019c850d1a7b143ca02e5" FOREIGN KEY ("modifiedById") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION` + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "issue" DROP CONSTRAINT "FK_da88a1019c850d1a7b143ca02e5"` + ); + await queryRunner.query( + `ALTER TABLE "issue" DROP CONSTRAINT "FK_10b17b49d1ee77e7184216001e0"` + ); + await queryRunner.query( + `ALTER TABLE "issue" DROP CONSTRAINT "FK_276e20d053f3cff1645803c95d8"` + ); + await queryRunner.query( + `ALTER TABLE "issue_comment" DROP CONSTRAINT "FK_180710fead1c94ca499c57a7d42"` + ); + await queryRunner.query( + `ALTER TABLE "issue_comment" DROP CONSTRAINT "FK_707b033c2d0653f75213614789d"` + ); + await queryRunner.query( + `ALTER TABLE "user_settings" DROP CONSTRAINT "FK_986a2b6d3c05eb4091bb8066f78"` + ); + await queryRunner.query( + `ALTER TABLE "user_push_subscription" DROP CONSTRAINT "FK_03f7958328e311761b0de675fbe"` + ); + await queryRunner.query( + `ALTER TABLE "watchlist" DROP CONSTRAINT "FK_6641da8d831b93dfcb429f8b8bc"` + ); + await queryRunner.query( + `ALTER TABLE "watchlist" DROP CONSTRAINT "FK_ae34e6b153a90672eb9dc4857d7"` + ); + await queryRunner.query( + `ALTER TABLE "season" DROP CONSTRAINT "FK_087099b39600be695591da9a49c"` + ); + await queryRunner.query( + `ALTER TABLE "media_request" DROP CONSTRAINT "FK_f4fc4efa14c3ba2b29c4525fa15"` + ); + await queryRunner.query( + `ALTER TABLE "media_request" DROP CONSTRAINT "FK_6997bee94720f1ecb7f31137095"` + ); + await queryRunner.query( + `ALTER TABLE "media_request" DROP CONSTRAINT "FK_a1aa713f41c99e9d10c48da75a0"` + ); + await queryRunner.query( + `ALTER TABLE "season_request" DROP CONSTRAINT "FK_6f14737e346d6b27d8e50d2157a"` + ); + await queryRunner.query( + `ALTER TABLE "blacklist" DROP CONSTRAINT "FK_62b7ade94540f9f8d8bede54b99"` + ); + await queryRunner.query( + `ALTER TABLE "blacklist" DROP CONSTRAINT "FK_53c1ab62c3e5875bc3ac474823e"` + ); + await queryRunner.query( + `DROP INDEX "public"."IDX_28c5d1d16da7908c97c9bc2f74"` + ); + await queryRunner.query(`DROP TABLE "session"`); + await queryRunner.query(`DROP TABLE "discover_slider"`); + await queryRunner.query(`DROP TABLE "issue"`); + await queryRunner.query(`DROP TABLE "issue_comment"`); + await queryRunner.query(`DROP TABLE "user"`); + await queryRunner.query(`DROP TABLE "user_settings"`); + await queryRunner.query(`DROP TABLE "user_push_subscription"`); + await queryRunner.query( + `DROP INDEX "public"."IDX_939f205946256cc0d2a1ac51a8"` + ); + await queryRunner.query(`DROP TABLE "watchlist"`); + await queryRunner.query( + `DROP INDEX "public"."IDX_7ff2d11f6a83cb52386eaebe74"` + ); + await queryRunner.query( + `DROP INDEX "public"."IDX_41a289eb1fa489c1bc6f38d9c3"` + ); + await queryRunner.query( + `DROP INDEX "public"."IDX_7157aad07c73f6a6ae3bbd5ef5"` + ); + await queryRunner.query(`DROP TABLE "media"`); + await queryRunner.query(`DROP TABLE "season"`); + await queryRunner.query(`DROP TABLE "media_request"`); + await queryRunner.query(`DROP TABLE "season_request"`); + await queryRunner.query( + `DROP INDEX "public"."IDX_6bbafa28411e6046421991ea21"` + ); + await queryRunner.query(`DROP TABLE "blacklist"`); + } +} diff --git a/server/migration/postgres/1734786596045-AddTelegramMessageThreadId.ts b/server/migration/postgres/1734786596045-AddTelegramMessageThreadId.ts new file mode 100644 index 000000000..a1b89b122 --- /dev/null +++ b/server/migration/postgres/1734786596045-AddTelegramMessageThreadId.ts @@ -0,0 +1,19 @@ +import type { MigrationInterface, QueryRunner } from 'typeorm'; + +export class AddTelegramMessageThreadId1734786596045 + implements MigrationInterface +{ + name = 'AddTelegramMessageThreadId1734786596045'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "user_settings" ADD "telegramMessageThreadId" character varying` + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "user_settings" DROP COLUMN "telegramMessageThreadId"` + ); + } +} diff --git a/server/migration/1734287582736-AddTelegramMessageThreadId.ts b/server/migration/sqlite/1734287582736-AddTelegramMessageThreadId.ts similarity index 100% rename from server/migration/1734287582736-AddTelegramMessageThreadId.ts rename to server/migration/sqlite/1734287582736-AddTelegramMessageThreadId.ts