feat(marketplace): add migrations 095-097 for products enrichment, previews, images
This commit is contained in:
parent
0110bf27ca
commit
e8ad5b5f4b
3 changed files with 50 additions and 0 deletions
14
veza-backend-api/migrations/095_products_enrichment.sql
Normal file
14
veza-backend-api/migrations/095_products_enrichment.sql
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
-- v0.401 M1: Add BPM, musical_key, category to products
|
||||||
|
-- Prerequisite: products table exists (GORM or prior migration)
|
||||||
|
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'products') THEN
|
||||||
|
ALTER TABLE products ADD COLUMN IF NOT EXISTS bpm INTEGER;
|
||||||
|
ALTER TABLE products ADD COLUMN IF NOT EXISTS musical_key VARCHAR(10);
|
||||||
|
ALTER TABLE products ADD COLUMN IF NOT EXISTS category VARCHAR(50);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_products_category ON products(category) WHERE category IS NOT NULL;
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_products_bpm ON products(bpm) WHERE bpm IS NOT NULL;
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_products_musical_key ON products(musical_key) WHERE musical_key IS NOT NULL AND musical_key != '';
|
||||||
|
END IF;
|
||||||
|
END $$;
|
||||||
18
veza-backend-api/migrations/096_product_previews.sql
Normal file
18
veza-backend-api/migrations/096_product_previews.sql
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
-- v0.401 M1: Product previews (audio demo files)
|
||||||
|
-- Prerequisite: products table exists
|
||||||
|
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'products') THEN
|
||||||
|
IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'product_previews') THEN
|
||||||
|
CREATE TABLE product_previews (
|
||||||
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||||
|
product_id UUID NOT NULL REFERENCES products(id) ON DELETE CASCADE,
|
||||||
|
file_path VARCHAR(512) NOT NULL,
|
||||||
|
duration_sec INTEGER,
|
||||||
|
created_at TIMESTAMPTZ DEFAULT NOW()
|
||||||
|
);
|
||||||
|
CREATE INDEX idx_product_previews_product_id ON product_previews(product_id);
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
END $$;
|
||||||
18
veza-backend-api/migrations/097_product_images.sql
Normal file
18
veza-backend-api/migrations/097_product_images.sql
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
-- v0.401 M1: Product images (multiple images per product)
|
||||||
|
-- Prerequisite: products table exists
|
||||||
|
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'products') THEN
|
||||||
|
IF NOT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'product_images') THEN
|
||||||
|
CREATE TABLE product_images (
|
||||||
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||||
|
product_id UUID NOT NULL REFERENCES products(id) ON DELETE CASCADE,
|
||||||
|
url VARCHAR(512) NOT NULL,
|
||||||
|
sort_order INTEGER DEFAULT 0,
|
||||||
|
created_at TIMESTAMPTZ DEFAULT NOW()
|
||||||
|
);
|
||||||
|
CREATE INDEX idx_product_images_product_id ON product_images(product_id);
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
|
END $$;
|
||||||
Loading…
Reference in a new issue