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:
Mert
2026-04-30 09:44:27 -04:00
committed by GitHub
parent 97c62136b7
commit b554664791
44 changed files with 1092 additions and 335 deletions
@@ -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);
}
+2 -2
View File
@@ -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