17 lines
465 B
SQL
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);
|