22 lines
732 B
MySQL
22 lines
732 B
MySQL
|
CREATE TYPE "PaymentMethod" AS ENUM (
|
||
|
'payu',
|
||
|
'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,
|
||
|
order_id int references shopping_carts (id),
|
||
|
quantity int not null default 0,
|
||
|
quantity_unit "QuantityUnit" not null,
|
||
|
CONSTRAINT positive_quantity check ( quantity >= 0 )
|
||
|
);
|