immich/server/src/schema/migrations/1773242919341-EncodedVideoAssetFiles.ts
Brandon Wees f3b7cd6198
refactor: move encoded video to asset files table (#26863)
* refactor: move encoded video to asset files table

* chore: update
2026-03-12 16:15:21 -04:00

26 lines
793 B
TypeScript

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);
}