mirror of
https://github.com/hexolan/stocklet.git
synced 2026-03-26 19:51:17 +00:00
chore: initial commit
This commit is contained in:
1
schema/sql/auth/000001_init_auth.down.sql
Normal file
1
schema/sql/auth/000001_init_auth.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS auth_methods CASCADE;
|
||||
4
schema/sql/auth/000001_init_auth.up.sql
Normal file
4
schema/sql/auth/000001_init_auth.up.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
CREATE TABLE auth_methods (
|
||||
user_id varchar(64) PRIMARY KEY,
|
||||
hashed_password varchar(128) NOT NULL
|
||||
);
|
||||
3
schema/sql/order/000001_init_order.down.sql
Normal file
3
schema/sql/order/000001_init_order.down.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
DROP TABLE IF EXISTS orders CASCADE;
|
||||
DROP TABLE IF EXISTS order_items CASCADE;
|
||||
DROP TABLE IF EXISTS event_outbox CASCADE;
|
||||
32
schema/sql/order/000001_init_order.up.sql
Normal file
32
schema/sql/order/000001_init_order.up.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
CREATE TABLE orders (
|
||||
id bigserial PRIMARY KEY,
|
||||
status smallint NOT NULL,
|
||||
|
||||
customer_id varchar(64) NOT NULL,
|
||||
shipment_id varchar(64),
|
||||
transaction_id varchar(64),
|
||||
|
||||
items_price money,
|
||||
total_price money,
|
||||
|
||||
created_at timestamp NOT NULL DEFAULT timezone('utc', now()),
|
||||
updated_at timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE order_items (
|
||||
order_id bigserial,
|
||||
product_id varchar(64),
|
||||
|
||||
quantity integer NOT NULL,
|
||||
|
||||
PRIMARY KEY (order_id, product_id),
|
||||
FOREIGN KEY (order_id) REFERENCES orders (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE event_outbox (
|
||||
id bigserial PRIMARY KEY,
|
||||
|
||||
aggregateid varchar(128) NOT NULL,
|
||||
aggregatetype varchar(128) NOT NULL,
|
||||
payload bytea NOT NULL
|
||||
);
|
||||
3
schema/sql/payment/000001_init_payment.down.sql
Normal file
3
schema/sql/payment/000001_init_payment.down.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
DROP TABLE IF EXISTS transactions CASCADE;
|
||||
DROP TABLE IF EXISTS customer_balances CASCADE;
|
||||
DROP TABLE IF EXISTS event_outbox CASCADE;
|
||||
24
schema/sql/payment/000001_init_payment.up.sql
Normal file
24
schema/sql/payment/000001_init_payment.up.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
CREATE TABLE transactions (
|
||||
id bigserial PRIMARY KEY,
|
||||
|
||||
order_id varchar(64),
|
||||
customer_id varchar(64) NOT NULL,
|
||||
|
||||
amount money NOT NULL,
|
||||
|
||||
reversed_at timestamp,
|
||||
processed_at timestamp NOT NULL DEFAULT timezone('utc', now())
|
||||
);
|
||||
|
||||
CREATE TABLE customer_balances (
|
||||
customer_id varchar(64) PRIMARY KEY,
|
||||
balance money NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE event_outbox (
|
||||
id bigserial PRIMARY KEY,
|
||||
|
||||
aggregateid varchar(128) NOT NULL,
|
||||
aggregatetype varchar(128) NOT NULL,
|
||||
payload bytea NOT NULL
|
||||
);
|
||||
2
schema/sql/product/000001_init_product.down.sql
Normal file
2
schema/sql/product/000001_init_product.down.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
DROP TABLE IF EXISTS products CASCADE;
|
||||
DROP TABLE IF EXISTS event_outbox CASCADE;
|
||||
18
schema/sql/product/000001_init_product.up.sql
Normal file
18
schema/sql/product/000001_init_product.up.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
CREATE TABLE products (
|
||||
id bigserial PRIMARY KEY,
|
||||
|
||||
name varchar(128) NOT NULL,
|
||||
description varchar(256) NOT NULL,
|
||||
price money NOT NULL,
|
||||
|
||||
created_at timestamp NOT NULL DEFAULT timezone('utc', now()),
|
||||
updated_at timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE event_outbox (
|
||||
id bigserial PRIMARY KEY,
|
||||
|
||||
aggregateid varchar(128) NOT NULL,
|
||||
aggregatetype varchar(128) NOT NULL,
|
||||
payload bytea NOT NULL
|
||||
);
|
||||
3
schema/sql/shipping/000001_init_shipping.down.sql
Normal file
3
schema/sql/shipping/000001_init_shipping.down.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
DROP TABLE IF EXISTS shipments CASCADE;
|
||||
DROP TABLE IF EXISTS shipment_items CASCADE;
|
||||
DROP TABLE IF EXISTS event_outbox CASCADE;
|
||||
26
schema/sql/shipping/000001_init_shipping.up.sql
Normal file
26
schema/sql/shipping/000001_init_shipping.up.sql
Normal file
@@ -0,0 +1,26 @@
|
||||
CREATE TABLE shipments (
|
||||
id bigserial PRIMARY KEY,
|
||||
order_id varchar(64) NOT NULL,
|
||||
|
||||
dispatched boolean DEFAULT FALSE,
|
||||
|
||||
created_at timestamp NOT NULL DEFAULT timezone('utc', now())
|
||||
);
|
||||
|
||||
CREATE TABLE shipment_items (
|
||||
shipment_id bigserial,
|
||||
product_id varchar(64),
|
||||
|
||||
quantity integer NOT NULL,
|
||||
|
||||
PRIMARY KEY (shipment_id, product_id),
|
||||
FOREIGN KEY (shipment_id) REFERENCES shipments (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE event_outbox (
|
||||
id bigserial PRIMARY KEY,
|
||||
|
||||
aggregateid varchar(128) NOT NULL,
|
||||
aggregatetype varchar(128) NOT NULL,
|
||||
payload bytea NOT NULL
|
||||
);
|
||||
2
schema/sql/user/000001_init_user.down.sql
Normal file
2
schema/sql/user/000001_init_user.down.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
DROP TABLE IF EXISTS users CASCADE;
|
||||
DROP TABLE IF EXISTS event_outbox CASCADE;
|
||||
19
schema/sql/user/000001_init_user.up.sql
Normal file
19
schema/sql/user/000001_init_user.up.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
CREATE TABLE users (
|
||||
id bigserial PRIMARY KEY,
|
||||
|
||||
first_name varchar(64) NOT NULL,
|
||||
last_name varchar(64) NOT NULL,
|
||||
|
||||
email varchar NOT NULL UNIQUE,
|
||||
|
||||
created_at timestamp NOT NULL DEFAULT timezone('utc', now()),
|
||||
updated_at timestamp
|
||||
);
|
||||
|
||||
CREATE TABLE event_outbox (
|
||||
id bigserial PRIMARY KEY,
|
||||
|
||||
aggregateid varchar(128) NOT NULL,
|
||||
aggregatetype varchar(128) NOT NULL,
|
||||
payload bytea NOT NULL
|
||||
);
|
||||
4
schema/sql/warehouse/000001_init_warehouse.down.sql
Normal file
4
schema/sql/warehouse/000001_init_warehouse.down.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
DROP TABLE IF EXISTS product_stock CASCADE;
|
||||
DROP TABLE IF EXISTS reservations CASCADE;
|
||||
DROP TABLE IF EXISTS reservation_items CASCADE;
|
||||
DROP TABLE IF EXISTS event_outbox CASCADE;
|
||||
30
schema/sql/warehouse/000001_init_warehouse.up.sql
Normal file
30
schema/sql/warehouse/000001_init_warehouse.up.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
CREATE TABLE product_stock (
|
||||
product_id varchar(64) PRIMARY KEY,
|
||||
quantity integer NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE reservations (
|
||||
id bigserial PRIMARY KEY,
|
||||
|
||||
order_id varchar(64) NOT NULL,
|
||||
|
||||
created_at timestamp NOT NULL DEFAULT timezone('utc', now())
|
||||
);
|
||||
|
||||
CREATE TABLE reservation_items (
|
||||
reservation_id bigserial,
|
||||
product_id varchar(64),
|
||||
|
||||
quantity integer NOT NULL,
|
||||
|
||||
PRIMARY KEY (reservation_id, product_id),
|
||||
FOREIGN KEY (reservation_id) REFERENCES reservations (id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE event_outbox (
|
||||
id bigserial PRIMARY KEY,
|
||||
|
||||
aggregateid varchar(128) NOT NULL,
|
||||
aggregatetype varchar(128) NOT NULL,
|
||||
payload bytea NOT NULL
|
||||
);
|
||||
Reference in New Issue
Block a user