LOOP-RUN-002 sample: admin order multi-filter, membership display price catalog, read-only refund_status. No real payment or RBAC. Co-authored-by: Cursor <cursoragent@cursor.com>
27 lines
812 B
SQL
27 lines
812 B
SQL
-- Ops-D: refund_status on orders + membership plan display prices
|
|
|
|
ALTER TABLE orders
|
|
ADD COLUMN IF NOT EXISTS refund_status TEXT NOT NULL DEFAULT 'none';
|
|
|
|
ALTER TABLE orders
|
|
DROP CONSTRAINT IF EXISTS orders_refund_status_check;
|
|
|
|
ALTER TABLE orders
|
|
ADD CONSTRAINT orders_refund_status_check
|
|
CHECK (refund_status IN ('none', 'pending', 'refunded', 'rejected'));
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_orders_status_created
|
|
ON orders (status, created_at DESC)
|
|
WHERE deleted_at IS NULL;
|
|
|
|
CREATE TABLE IF NOT EXISTS membership_plan_prices (
|
|
plan TEXT PRIMARY KEY,
|
|
display_cents INT NOT NULL CHECK (display_cents >= 0),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
);
|
|
|
|
INSERT INTO membership_plan_prices(plan, display_cents) VALUES
|
|
('monthly', 2800),
|
|
('yearly', 19800)
|
|
ON CONFLICT (plan) DO NOTHING;
|