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:
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