CREATE TABLE IF NOT EXISTS bazzar_pos.shopping_bag_rules (
    id BIGSERIAL PRIMARY KEY,
    enabled BOOLEAN NOT NULL DEFAULT FALSE,
    min_total NUMERIC(18,2) NOT NULL DEFAULT 0,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);

CREATE TABLE IF NOT EXISTS bazzar_pos.shopping_bag_rule_items (
    id BIGSERIAL PRIMARY KEY,
    rule_id BIGINT NOT NULL REFERENCES bazzar_pos.shopping_bag_rules(id) ON DELETE CASCADE,
    product_id BIGINT NOT NULL REFERENCES bazzar_pos.products(id),
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    UNIQUE (rule_id, product_id)
);
