mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
chore!: duration in milliseconds (#28003)
* server changes * openapi * web changes * mobile changes * assume 3.0 client * deprecate * review feedback * update medium tests * linting
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { Kysely, sql } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<any>): Promise<void> {
|
||||
await sql`
|
||||
ALTER TABLE asset
|
||||
ALTER COLUMN duration TYPE integer
|
||||
USING (
|
||||
CASE
|
||||
WHEN duration ~ '^\\d{2}:\\d{2}:\\d{2}\\.\\d{3}$'
|
||||
THEN substr(duration, 1, 2)::int * 3600000
|
||||
+ substr(duration, 4, 2)::int * 60000
|
||||
+ substr(duration, 7, 2)::int * 1000
|
||||
+ substr(duration, 10, 3)::int
|
||||
END
|
||||
);`.execute(db);
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
await sql`
|
||||
ALTER TABLE asset
|
||||
ALTER COLUMN duration TYPE varchar
|
||||
USING (
|
||||
CASE
|
||||
WHEN duration IS NULL THEN NULL
|
||||
ELSE lpad((duration / 3600000)::text, 2, '0')
|
||||
|| ':' || lpad(((duration / 60000) % 60)::text, 2, '0')
|
||||
|| ':' || lpad(((duration / 1000) % 60)::text, 2, '0')
|
||||
|| '.' || lpad((duration % 1000)::text, 3, '0')
|
||||
END
|
||||
);`.execute(db);
|
||||
}
|
||||
@@ -83,8 +83,8 @@ export class AssetTable {
|
||||
@Column({ type: 'boolean', default: false })
|
||||
isFavorite!: Generated<boolean>;
|
||||
|
||||
@Column({ type: 'character varying', nullable: true })
|
||||
duration!: string | null;
|
||||
@Column({ type: 'integer', nullable: true })
|
||||
duration!: number | null;
|
||||
|
||||
@Column({ type: 'bytea', index: true })
|
||||
checksum!: Buffer; // sha1 checksum
|
||||
|
||||
Reference in New Issue
Block a user