-- Daily Deals schema for local PostgreSQL -- Synced from production MySQL product_daily_deals + product_current_prices CREATE TABLE IF NOT EXISTS product_daily_deals ( deal_id serial PRIMARY KEY, deal_date date NOT NULL, pid bigint NOT NULL, price_id bigint NOT NULL, -- Denormalized from product_current_prices so we don't need to sync that whole table deal_price numeric(10,3), created_at timestamptz DEFAULT NOW(), CONSTRAINT fk_daily_deals_pid FOREIGN KEY (pid) REFERENCES products(pid) ON DELETE CASCADE ); CREATE INDEX IF NOT EXISTS idx_daily_deals_date ON product_daily_deals(deal_date); CREATE INDEX IF NOT EXISTS idx_daily_deals_pid ON product_daily_deals(pid); CREATE UNIQUE INDEX IF NOT EXISTS idx_daily_deals_unique ON product_daily_deals(deal_date, pid);