-- Migration 008: per-domain discount table
SET search_path TO crawl;

CREATE TABLE IF NOT EXISTS discounts (
    id         BIGSERIAL    PRIMARY KEY,
    domain     VARCHAR(255) NOT NULL UNIQUE,
    discount   NUMERIC(5,4) NOT NULL CHECK (discount > 0 AND discount <= 1),
    note       TEXT,
    created_at TIMESTAMPTZ  NOT NULL DEFAULT NOW(),
    updated_at TIMESTAMPTZ  NOT NULL DEFAULT NOW()
);

CREATE INDEX IF NOT EXISTS idx_discounts_domain ON discounts (domain);
