21 lines
555 B
SQL
21 lines
555 B
SQL
CREATE TYPE IF NOT EXISTS asset_variant_kind AS ENUM (
|
|
'thumb',
|
|
'poster',
|
|
'video_mp4'
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS asset_variants (
|
|
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
asset_id uuid NOT NULL REFERENCES assets(id) ON DELETE CASCADE,
|
|
kind asset_variant_kind NOT NULL,
|
|
size int NOT NULL,
|
|
key text NOT NULL,
|
|
mime_type text NOT NULL,
|
|
width int,
|
|
height int,
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
UNIQUE(asset_id, kind, size)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS asset_variants_asset_id_idx ON asset_variants(asset_id);
|