2022-04-16 06:58:48 +02:00
|
|
|
CREATE TYPE "PaymentMethod" AS ENUM (
|
2022-04-16 07:31:19 +02:00
|
|
|
'pay_u',
|
2022-04-16 06:58:48 +02:00
|
|
|
'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,
|
2022-04-16 07:31:19 +02:00
|
|
|
shopping_cart_id int references shopping_carts (id),
|
2022-04-16 06:58:48 +02:00
|
|
|
quantity int not null default 0,
|
|
|
|
quantity_unit "QuantityUnit" not null,
|
|
|
|
CONSTRAINT positive_quantity check ( quantity >= 0 )
|
|
|
|
);
|