cdb/migrations/0000_init.sql

33 lines
913 B
MySQL
Raw Normal View History

2024-10-07 18:53:58 +00:00
CREATE TABLE flows (
id UUID NOT NULL PRIMARY KEY DEFAULT gen_random_uuid(),
"started" timestamptz NOT NULL DEFAULT current_timestamp,
kind TEXT NOT NULL,
input UUID[],
ended timestamptz,
"next" UUID,
produced UUID[],
2024-10-07 19:23:16 +00:00
FOREIGN KEY("next") REFERENCES flows(id)
2024-10-07 18:53:58 +00:00
);
CREATE TABLE flow_notes (
id UUID NOT NULL PRIMARY KEY DEFAULT gen_random_uuid(),
time timestamptz NOT NULL DEFAULT current_timestamp,
content TEXT NOT NULL,
on_flow UUID NOT NULL,
2024-10-07 19:28:07 +00:00
FOREIGN KEY(on_flow) REFERENCES flows(id)
2024-10-07 18:53:58 +00:00
);
CREATE TABLE transactions (
id UUID NOT NULL PRIMARY KEY DEFAULT gen_random_uuid(),
created timestamptz NOT NULL DEFAULT current_timestamp,
item TEXT NOT NULL,
variant TEXT NOT NULL,
2024-10-07 19:53:11 +00:00
price DOUBLE PRECISION,
2024-10-07 18:53:58 +00:00
origin TEXT,
"location" TEXT,
note TEXT,
destination TEXT,
consumed_price NUMERIC(2),
consumed_timestamp timestamptz
);