Rebasely Beta: data may be purged

examples/storefront Public

SQL · 16 lines · 587 B · at 82cc041

-- Carts and what is in them. unit_price_cents is the price when the item was added.CREATE TABLE carts (  id TEXT PRIMARY KEY,  status TEXT NOT NULL DEFAULT 'open' CHECK (status IN ('open', 'checked_out')),  created_at INTEGER NOT NULL,  updated_at INTEGER NOT NULL);CREATE TABLE cart_items (  cart_id TEXT NOT NULL REFERENCES carts (id) ON DELETE CASCADE,  product_id TEXT NOT NULL REFERENCES products (id),  quantity INTEGER NOT NULL CHECK (quantity BETWEEN 1 AND 10),  unit_price_cents INTEGER NOT NULL,  added_at INTEGER NOT NULL,  PRIMARY KEY (cart_id, product_id));