update
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
-- TODO: Add variables for db, user name, etc...
|
||||
|
||||
CREATE DATABASE svc_identity
|
||||
WITH
|
||||
OWNER = postgres
|
||||
ENCODING = 'UTF8'
|
||||
CONNECTION LIMIT = -1;
|
||||
|
||||
GRANT ALL ON DATABASE svc_identity TO postgres;
|
||||
@@ -0,0 +1,2 @@
|
||||
DROP TABLE IF EXISTS basket.basket_item;
|
||||
DROP TABLE IF EXISTS basket.basket;
|
||||
@@ -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...
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE IF EXISTS basket.basket_item
|
||||
DROP COLUMN price;
|
||||
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE IF EXISTS basket.basket_item
|
||||
ADD COLUMN price double precision NOT NULL DEFAULT 0.00;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS catalog.product;
|
||||
@@ -0,0 +1,16 @@
|
||||
CREATE TABLE catalog.product
|
||||
(
|
||||
id integer NOT NULL GENERATED ALWAYS AS IDENTITY,
|
||||
pid character varying NOT NULL,
|
||||
name character varying NOT NULL,
|
||||
price double precision NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL DEFAULT now(),
|
||||
updated_at timestamp without time zone,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
ALTER TABLE IF EXISTS catalog.product
|
||||
OWNER to postgres;
|
||||
|
||||
COMMENT ON COLUMN catalog.product.pid
|
||||
IS 'Unique product ID. EAN, UPC etc...';
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS identity.users;
|
||||
@@ -0,0 +1,12 @@
|
||||
CREATE TABLE IF NOT EXISTS identity.users
|
||||
(
|
||||
id uuid NOT NULL DEFAULT gen_random_uuid(),
|
||||
username character varying NOT NULL,
|
||||
email character varying NOT NULL,
|
||||
created_at timestamp without time zone NOT NULL DEFAULT now(),
|
||||
updated_at timestamp without time zone,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
ALTER TABLE IF EXISTS identity.users
|
||||
OWNER to postgres;
|
||||
@@ -0,0 +1,2 @@
|
||||
DROP TABLE IF EXISTS ordering.order_item;
|
||||
DROP TABLE IF EXISTS ordering."order";
|
||||
@@ -0,0 +1,34 @@
|
||||
CREATE TABLE IF NOT EXISTS ordering."order"
|
||||
(
|
||||
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 ordering.order_item
|
||||
(
|
||||
id uuid NOT NULL DEFAULT gen_random_uuid(),
|
||||
order_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 ordering.order_item
|
||||
ADD CONSTRAINT order_item_order_fkey FOREIGN KEY (order_id)
|
||||
REFERENCES "ordering"."order" (id) MATCH SIMPLE
|
||||
ON UPDATE NO ACTION
|
||||
ON DELETE NO ACTION
|
||||
NOT VALID;
|
||||
|
||||
ALTER TABLE IF EXISTS "ordering"."order"
|
||||
OWNER to postgres;
|
||||
|
||||
ALTER TABLE IF EXISTS "ordering".order_item
|
||||
OWNER to postgres;
|
||||
-- TODO ^^ PRIVILEGES...
|
||||
Reference in New Issue
Block a user