mirror of
https://github.com/immich-app/immich.git
synced 2026-03-23 10:29:42 +03:00
refactor: move encoded video to asset files table (#26863)
* refactor: move encoded video to asset files table * chore: update
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user