bazzar/db/migrate/202204161233_add_cart_state.sql

11 lines
256 B
SQL

CREATE TYPE "ShoppingCartState" AS ENUM (
'active',
'closed'
);
ALTER TABLE shopping_carts
ADD COLUMN "state" "ShoppingCartState" NOT NULL DEFAULT 'active';
ALTER TABLE shopping_carts
ADD CONSTRAINT single_active_cart UNIQUE (buyer_id, "state");