Update & Refactor
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS basket.basket
|
||||
(
|
||||
id uuid NOT NULL DEFAULT gen_random_uuid(),
|
||||
state character varying NOT NULL DEFAULT 'new',
|
||||
"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)
|
||||
@@ -13,7 +13,7 @@ CREATE TABLE IF NOT EXISTS basket.basket_item
|
||||
basket_id uuid NOT NULL,
|
||||
product_id integer NOT NULL,
|
||||
quantity integer NOT NULL DEFAULT 1,
|
||||
price double precision NOT NULL DEFAULT 0.00;
|
||||
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)
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
ALTER TABLE IF EXISTS basket.basket_item
|
||||
DROP COLUMN price;
|
||||
@@ -1,2 +0,0 @@
|
||||
ALTER TABLE IF EXISTS basket.basket_item
|
||||
ADD COLUMN price double precision NOT NULL DEFAULT 0.00;
|
||||
@@ -1,8 +1,8 @@
|
||||
CREATE TABLE catalog.product
|
||||
(
|
||||
id integer NOT NULL GENERATED ALWAYS AS IDENTITY,
|
||||
pid character varying NOT NULL,
|
||||
name character varying NOT NULL,
|
||||
pid uuid NOT NULL DEFAULT gen_random_uuid(),
|
||||
"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,
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
CREATE USER egommerce;
|
||||
CREATE DATABASE egommerce;
|
||||
|
||||
GRANT ALL PRIVILEGES ON DATABASE egommerce TO egommerce;
|
||||
|
||||
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
DROP TABLE IF EXISTS ordering.order_item;
|
||||
DROP TABLE IF EXISTS ordering."order";
|
||||
DROP TABLE IF EXISTS "ordering".order_item;
|
||||
DROP TABLE IF EXISTS "ordering"."order";
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
CREATE TABLE IF NOT EXISTS ordering."order"
|
||||
CREATE TABLE IF NOT EXISTS "ordering"."order"
|
||||
(
|
||||
id uuid NOT NULL DEFAULT gen_random_uuid(),
|
||||
state character varying NOT NULL DEFAULT 'new',
|
||||
"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
|
||||
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;
|
||||
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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user