This commit is contained in:
PB
2022-12-25 23:21:27 +01:00
parent 317d1a871b
commit 6042f81c35
14 changed files with 219 additions and 41 deletions

View File

@@ -0,0 +1,2 @@
DROP TABLE IF EXISTS basket.basket_item;
DROP TABLE IF EXISTS basket.basket;

View File

@@ -0,0 +1,34 @@
CREATE TABLE IF NOT EXISTS basket.basket
(
id uuid NOT NULL DEFAULT gen_random_uuid(),
state character varying NOT NULL DEFAULT 'new',
created_at timestamp without time zone NOT NULL DEFAULT now(),
updated_at timestamp without time zone,
PRIMARY KEY (id)
);
CREATE TABLE IF NOT EXISTS basket.basket_item
(
id uuid NOT NULL DEFAULT gen_random_uuid(),
basket_id uuid NOT NULL,
product_id integer NOT NULL,
quantity integer NOT NULL DEFAULT 1,
price double precision NOT NULL DEFAULT 0.00;
created_at timestamp without time zone NOT NULL DEFAULT now(),
updated_at timestamp without time zone,
PRIMARY KEY (id)
);
ALTER TABLE IF EXISTS basket.basket_item
ADD CONSTRAINT basket_item_basket_fkey FOREIGN KEY (basket_id)
REFERENCES basket.basket (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
ALTER TABLE IF EXISTS basket.basket
OWNER to postgres;
ALTER TABLE IF EXISTS basket.basket_item
OWNER to postgres;
-- TODO ^^ PRIVILEGES...

View File

@@ -0,0 +1,2 @@
ALTER TABLE IF EXISTS basket.basket_item
DROP COLUMN price;

View File

@@ -0,0 +1,2 @@
ALTER TABLE IF EXISTS basket.basket_item
ADD COLUMN price double precision NOT NULL DEFAULT 0.00;