Backend (Go): - Config: CORS, RabbitMQ, rate limit, main config updates - Routes: core, distribution, tracks routing changes - Middleware: rate limiter, endpoint limiter, response cache hardening - Handlers: distribution, search handler fixes - Workers: job worker improvements - Upload validator and logging config additions - New migrations: products, orders, performance indexes - Seed tooling and data Stream Server (Rust): - Audio processing, config, routes, simple stream server updates - Dockerfile improvements Infrastructure: - docker-compose.yml updates - nginx-rtmp config changes - Makefile improvements (config, dev, high, infra) - Root package.json and lock file updates - .env.example updates Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
46 lines
1.9 KiB
SQL
46 lines
1.9 KiB
SQL
-- Create orders and order_items tables (missing from prior migrations)
|
|
-- Required before 100_orders_discount.sql which ALTERs orders
|
|
|
|
CREATE TABLE IF NOT EXISTS orders (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
buyer_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
total_amount DECIMAL(10,2) NOT NULL,
|
|
currency VARCHAR(3) DEFAULT 'EUR',
|
|
status VARCHAR(50) DEFAULT 'pending',
|
|
payment_intent TEXT,
|
|
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
updated_at TIMESTAMPTZ DEFAULT NOW()
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_orders_buyer_id ON orders(buyer_id);
|
|
CREATE INDEX IF NOT EXISTS idx_orders_status ON orders(status);
|
|
CREATE INDEX IF NOT EXISTS idx_orders_created_at ON orders(created_at DESC);
|
|
|
|
CREATE TABLE IF NOT EXISTS order_items (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
order_id UUID NOT NULL REFERENCES orders(id) ON DELETE CASCADE,
|
|
product_id UUID NOT NULL REFERENCES products(id) ON DELETE CASCADE,
|
|
price DECIMAL(10,2) NOT NULL,
|
|
created_at TIMESTAMPTZ DEFAULT NOW()
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_order_items_order_id ON order_items(order_id);
|
|
CREATE INDEX IF NOT EXISTS idx_order_items_product_id ON order_items(product_id);
|
|
|
|
-- Licenses table (for purchased licenses)
|
|
CREATE TABLE IF NOT EXISTS licenses (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
buyer_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
track_id UUID NOT NULL REFERENCES tracks(id) ON DELETE CASCADE,
|
|
product_id UUID NOT NULL REFERENCES products(id) ON DELETE CASCADE,
|
|
order_id UUID NOT NULL REFERENCES orders(id) ON DELETE CASCADE,
|
|
type VARCHAR(50) NOT NULL,
|
|
rights JSONB,
|
|
downloads_left INT DEFAULT 3,
|
|
created_at TIMESTAMPTZ DEFAULT NOW(),
|
|
expires_at TIMESTAMPTZ,
|
|
revoked_at TIMESTAMPTZ
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_licenses_buyer_id ON licenses(buyer_id);
|
|
CREATE INDEX IF NOT EXISTS idx_licenses_order_id ON licenses(order_id);
|