refactor: move encoded video to asset files table (#26863)

* refactor: move encoded video to asset files table

* chore: update
This commit is contained in:
Brandon Wees
2026-03-12 15:15:21 -05:00
committed by GitHub
parent 990aff441b
commit f3b7cd6198
19 changed files with 158 additions and 60 deletions

View File

@@ -0,0 +1,25 @@
import { Kysely, sql } from 'kysely';
export async function up(db: Kysely<any>): Promise<void> {
await sql`
INSERT INTO "asset_file" ("assetId", "type", "path")
SELECT "id", 'encoded_video', "encodedVideoPath"
FROM "asset"
WHERE "encodedVideoPath" IS NOT NULL AND "encodedVideoPath" != '';
`.execute(db);
await sql`ALTER TABLE "asset" DROP COLUMN "encodedVideoPath";`.execute(db);
}
export async function down(db: Kysely<any>): Promise<void> {
await sql`ALTER TABLE "asset" ADD "encodedVideoPath" character varying DEFAULT '';`.execute(db);
await sql`
UPDATE "asset"
SET "encodedVideoPath" = af."path"
FROM "asset_file" af
WHERE "asset"."id" = af."assetId"
AND af."type" = 'encoded_video'
AND af."isEdited" = false;
`.execute(db);
}

View File

@@ -92,9 +92,6 @@ export class AssetTable {
@Column({ type: 'character varying', nullable: true })
duration!: string | null;
@Column({ type: 'character varying', nullable: true, default: '' })
encodedVideoPath!: string | null;
@Column({ type: 'bytea', index: true })
checksum!: Buffer; // sha1 checksum