diff --git a/server/migration/postgres/1744317469293-AddPlexProfilesSupport.ts b/server/migration/postgres/1744317469293-AddPlexProfilesSupport.ts deleted file mode 100644 index 29bc1477..00000000 --- a/server/migration/postgres/1744317469293-AddPlexProfilesSupport.ts +++ /dev/null @@ -1,31 +0,0 @@ -// Create a new migration file -import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'; - -export class AddPlexProfilesSupport1744317469293 implements MigrationInterface { - name = 'AddPlexProfilesSupport1744317469293'; - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.addColumns('user', [ - new TableColumn({ - name: 'plexProfileId', - type: 'varchar', - isNullable: true, - }), - new TableColumn({ - name: 'isPlexProfile', - type: 'boolean', - default: false, - }), - new TableColumn({ - name: 'mainPlexUserId', - type: 'integer', - isNullable: true, - }), - ]); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.dropColumn('user', 'plexProfileId'); - await queryRunner.dropColumn('user', 'isPlexProfile'); - await queryRunner.dropColumn('user', 'mainPlexUserId'); - } -} diff --git a/server/migration/postgres/1745254842580-AddPlexProfilesSupport.ts b/server/migration/postgres/1745254842580-AddPlexProfilesSupport.ts new file mode 100644 index 00000000..8428fca1 --- /dev/null +++ b/server/migration/postgres/1745254842580-AddPlexProfilesSupport.ts @@ -0,0 +1,24 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddPlexProfilesSupport1745254842580 implements MigrationInterface { + name = 'AddPlexProfilesSupport1745254842580' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "user" ADD "plexProfileId" character varying`); + await queryRunner.query(`ALTER TABLE "user" ADD "isPlexProfile" boolean NOT NULL DEFAULT false`); + await queryRunner.query(`ALTER TABLE "user" ADD "mainPlexUserId" integer`); + await queryRunner.query(`ALTER TABLE "user" ADD "avatarETag" character varying`); + await queryRunner.query(`ALTER TABLE "user" ADD "avatarVersion" character varying`); + await queryRunner.query(`ALTER TABLE "blacklist" ADD "blacklistedTags" character varying`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "blacklist" DROP COLUMN "blacklistedTags"`); + await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "avatarVersion"`); + await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "avatarETag"`); + await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "mainPlexUserId"`); + await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "isPlexProfile"`); + await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "plexProfileId"`); + } + +} \ No newline at end of file diff --git a/server/migration/sqlite/1744317469293-AddPlexProfilesSupport.ts b/server/migration/sqlite/1744317469293-AddPlexProfilesSupport.ts deleted file mode 100644 index 29bc1477..00000000 --- a/server/migration/sqlite/1744317469293-AddPlexProfilesSupport.ts +++ /dev/null @@ -1,31 +0,0 @@ -// Create a new migration file -import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'; - -export class AddPlexProfilesSupport1744317469293 implements MigrationInterface { - name = 'AddPlexProfilesSupport1744317469293'; - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.addColumns('user', [ - new TableColumn({ - name: 'plexProfileId', - type: 'varchar', - isNullable: true, - }), - new TableColumn({ - name: 'isPlexProfile', - type: 'boolean', - default: false, - }), - new TableColumn({ - name: 'mainPlexUserId', - type: 'integer', - isNullable: true, - }), - ]); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.dropColumn('user', 'plexProfileId'); - await queryRunner.dropColumn('user', 'isPlexProfile'); - await queryRunner.dropColumn('user', 'mainPlexUserId'); - } -} diff --git a/server/migration/sqlite/1745254842580-AddPlexProfilesSupport.ts b/server/migration/sqlite/1745254842580-AddPlexProfilesSupport.ts new file mode 100644 index 00000000..5cbb8fbc --- /dev/null +++ b/server/migration/sqlite/1745254842580-AddPlexProfilesSupport.ts @@ -0,0 +1,28 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class AddPlexProfilesSupport1745254842580 implements MigrationInterface { + name = 'AddPlexProfilesSupport1745254842580' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE "temporary_user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar, "createdAt" datetime DEFAULT (datetime('now')), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`); + await queryRunner.query(`INSERT INTO "temporary_user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt") SELECT "id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt" FROM "user_push_subscription"`); + await queryRunner.query(`DROP TABLE "user_push_subscription"`); + await queryRunner.query(`ALTER TABLE "temporary_user_push_subscription" RENAME TO "user_push_subscription"`); + await queryRunner.query(`CREATE TABLE "temporary_user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar, "createdAt" datetime DEFAULT (datetime('now')), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`); + await queryRunner.query(`INSERT INTO "temporary_user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt") SELECT "id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt" FROM "user_push_subscription"`); + await queryRunner.query(`DROP TABLE "user_push_subscription"`); + await queryRunner.query(`ALTER TABLE "temporary_user_push_subscription" RENAME TO "user_push_subscription"`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "user_push_subscription" RENAME TO "temporary_user_push_subscription"`); + await queryRunner.query(`CREATE TABLE "user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar, "createdAt" datetime DEFAULT (datetime('now')), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`); + await queryRunner.query(`INSERT INTO "user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt") SELECT "id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt" FROM "temporary_user_push_subscription"`); + await queryRunner.query(`DROP TABLE "temporary_user_push_subscription"`); + await queryRunner.query(`ALTER TABLE "user_push_subscription" RENAME TO "temporary_user_push_subscription"`); + await queryRunner.query(`CREATE TABLE "user_push_subscription" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "endpoint" varchar NOT NULL, "p256dh" varchar NOT NULL, "auth" varchar NOT NULL, "userId" integer, "userAgent" varchar, "createdAt" datetime DEFAULT (datetime('now')), CONSTRAINT "UQ_f90ab5a4ed54905a4bb51a7148b" UNIQUE ("auth"), CONSTRAINT "FK_03f7958328e311761b0de675fbe" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`); + await queryRunner.query(`INSERT INTO "user_push_subscription"("id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt") SELECT "id", "endpoint", "p256dh", "auth", "userId", "userAgent", "createdAt" FROM "temporary_user_push_subscription"`); + await queryRunner.query(`DROP TABLE "temporary_user_push_subscription"`); + } + +}