CREATE TYPE "PaymentMethod" AS ENUM (
    'pay_u',
    'payment_on_the_spot'
    );

CREATE TABLE shopping_carts
(
    id             serial                       not null primary key,
    buyer_id       int references accounts (id) not null,
    payment_method "PaymentMethod"              NOT NULL DEFAULT 'payment_on_the_spot'
);

CREATE TABLE shopping_cart_items
(
    id            serial                       not null primary key,
    product_id    int references products (id) not null,
    shopping_cart_id      int references shopping_carts (id),
    quantity      int                          not null default 0,
    quantity_unit "QuantityUnit"               not null,
    CONSTRAINT positive_quantity check ( quantity >= 0 )
);
