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 (
|
2022-11-11 16:32:07 +01:00
|
|
|
id serial NOT NULL,
|
2022-11-04 18:40:14 +01:00
|
|
|
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 (
|
2022-11-11 16:32:07 +01:00
|
|
|
id serial NOT NULL,
|
2022-11-23 16:03:58 +01:00
|
|
|
product_variant_id integer NOT NULL,
|
2022-11-04 18:40:14 +01:00
|
|
|
shopping_cart_id integer,
|
|
|
|
quantity integer DEFAULT 0 NOT NULL,
|
|
|
|
quantity_unit "QuantityUnit" NOT NULL,
|
|
|
|
CONSTRAINT positive_quantity CHECK ((quantity >= 0))
|
|
|
|
);
|