Files
stocklet/schema/sql/shipping/000001_init_shipping.up.sql
2024-04-16 22:27:52 +01:00

26 lines
606 B
SQL

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
);