bazzar/crates/cart_manager/migrations/202204131841_init.sql

34 lines
788 B
MySQL
Raw Normal View History

2022-11-04 18:40:14 +01:00
CREATE TYPE "PaymentMethod" AS ENUM (
'pay_u',
'payment_on_the_spot'
);
CREATE TYPE "ShoppingCartState" AS ENUM (
'active',
'closed'
);
CREATE TYPE "QuantityUnit" AS ENUM (
'g',
'dkg',
'kg',
'piece'
);
CREATE TABLE shopping_carts (
id integer NOT NULL,
buyer_id integer NOT NULL,
payment_method "PaymentMethod" DEFAULT 'payment_on_the_spot'::"PaymentMethod" NOT NULL,
state "ShoppingCartState" DEFAULT 'active'::"ShoppingCartState" NOT NULL,
checkout_notes text
);
CREATE TABLE shopping_cart_items (
id integer NOT NULL,
product_id integer NOT NULL,
shopping_cart_id integer,
quantity integer DEFAULT 0 NOT NULL,
quantity_unit "QuantityUnit" NOT NULL,
CONSTRAINT positive_quantity CHECK ((quantity >= 0))
);