-- +goose Up -- +goose StatementBegin CREATE TABLE attachment_variants ( attachment_id UUID NOT NULL REFERENCES attachments(id) ON DELETE CASCADE, name TEXT NOT NULL, object_key TEXT NOT NULL, content_type TEXT NOT NULL, size_bytes BIGINT NOT NULL, width INT NOT NULL, height INT NOT NULL, sha256 BYTEA NOT NULL, created_at TIMESTAMPTZ NOT NULL DEFAULT now(), CONSTRAINT attachment_variants_pkey PRIMARY KEY (attachment_id, name), CONSTRAINT attachment_variants_name_chk CHECK (name IN ('thumbnail', 'crop', 'webp')), CONSTRAINT attachment_variants_size_chk CHECK (size_bytes > 0), CONSTRAINT attachment_variants_sha256_len CHECK (octet_length(sha256) = 32) ); -- +goose StatementEnd -- +goose Down -- +goose StatementBegin DROP TABLE IF EXISTS attachment_variants; -- +goose StatementEnd