cdb/migrations/0000_init.sql
2024-10-07 21:53:11 +02:00

32 lines
913 B
SQL

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[],
FOREIGN KEY("next") REFERENCES flows(id)
);
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,
FOREIGN KEY(on_flow) REFERENCES flows(id)
);
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,
price DOUBLE PRECISION,
origin TEXT,
"location" TEXT,
note TEXT,
destination TEXT,
consumed_price NUMERIC(2),
consumed_timestamp timestamptz
);