fix(db): re-generate correct database migrations

This commit is contained in:
0xsysr3ll
2025-04-21 19:31:59 +02:00
parent 7f28834073
commit a234d57335
4 changed files with 52 additions and 62 deletions

View File

@@ -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<void> {
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<void> {
await queryRunner.dropColumn('user', 'plexProfileId');
await queryRunner.dropColumn('user', 'isPlexProfile');
await queryRunner.dropColumn('user', 'mainPlexUserId');
}
}

View File

@@ -0,0 +1,24 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddPlexProfilesSupport1745254842580 implements MigrationInterface {
name = 'AddPlexProfilesSupport1745254842580'
public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
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"`);
}
}

View File

@@ -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<void> {
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<void> {
await queryRunner.dropColumn('user', 'plexProfileId');
await queryRunner.dropColumn('user', 'isPlexProfile');
await queryRunner.dropColumn('user', 'mainPlexUserId');
}
}

View File

@@ -0,0 +1,28 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddPlexProfilesSupport1745254842580 implements MigrationInterface {
name = 'AddPlexProfilesSupport1745254842580'
public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
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"`);
}
}