veza/veza-backend-api/migrations/098_product_licenses.sql

20 lines
846 B
MySQL
Raw Normal View History

-- v0.401 M2: Product licenses (multiple license types per product with price and terms)
-- Types: streaming, personal, commercial, exclusive
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_licenses') THEN
CREATE TABLE product_licenses (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
product_id UUID NOT NULL REFERENCES products(id) ON DELETE CASCADE,
license_type VARCHAR(50) NOT NULL,
price_cents INTEGER NOT NULL,
terms_text TEXT,
created_at TIMESTAMPTZ DEFAULT NOW()
);
CREATE INDEX idx_product_licenses_product_id ON product_licenses(product_id);
END IF;
END IF;
END $$;