max / makenotwork
| 1 | -- Shopping cart: persistent across sessions/devices, one row per item per user. |
| 2 | -- Mirrors the wishlists table structure (composite PK, CASCADE deletes). |
| 3 | NOT EXISTS cart_items ( |
| 4 | user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE, |
| 5 | item_id UUID NOT NULL REFERENCES items(id) ON DELETE CASCADE, |
| 6 | created_at TIMESTAMPTZ NOT NULL DEFAULT NOW, |
| 7 | PRIMARY KEY (user_id, item_id) |
| 8 | ); |
| 9 | |
| 10 | NOT EXISTS idx_cart_items_item ON cart_items(item_id); |
| 11 |