Files
porthole/packages/db/migrations/0002_assets_duration_and_indexes.sql
OpenCode Test e1a64aa092 Initial commit
2025-12-24 10:50:10 -08:00

17 lines
465 B
SQL

-- Task 2 follow-up: align schema with PLAN.md
-- 1) duration_seconds should be int (seconds)
ALTER TABLE assets
ALTER COLUMN duration_seconds
TYPE int
USING (
CASE
WHEN duration_seconds IS NULL THEN NULL
ELSE round(duration_seconds)::int
END
);
-- 2) source_key uniqueness should be per-bucket
DROP INDEX IF EXISTS assets_source_key_idx;
CREATE UNIQUE INDEX IF NOT EXISTS assets_bucket_source_key_uidx ON assets (bucket, source_key);