feat(postgres): Add initial table schema for Finito tables
This commit is contained in:
parent
fe97c712cc
commit
cbb58fa6c2
3 changed files with 42 additions and 1 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,4 @@
|
|||
|
||||
.envrc
|
||||
/target/
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
DROP TABLE actions;
|
||||
DROP TYPE ActionStatus;
|
||||
DROP TABLE events;
|
||||
DROP TABLE machines;
|
|
@ -0,0 +1,37 @@
|
|||
-- Creates the initial schema required by finito-postgres.
|
||||
|
||||
CREATE TABLE machines (
|
||||
id UUID PRIMARY KEY,
|
||||
created TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
fsm TEXT NOT NULL,
|
||||
state JSONB NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE events (
|
||||
id UUID PRIMARY KEY,
|
||||
created TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
fsm TEXT NOT NULL,
|
||||
fsm_id UUID NOT NULL REFERENCES machines(id),
|
||||
event JSONB NOT NULL
|
||||
);
|
||||
CREATE INDEX idx_events_machines ON events(fsm_id);
|
||||
|
||||
CREATE TYPE ActionStatus AS ENUM (
|
||||
'Pending',
|
||||
'Completed',
|
||||
'Failed'
|
||||
);
|
||||
|
||||
CREATE TABLE actions (
|
||||
id UUID PRIMARY KEY,
|
||||
created TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
fsm TEXT NOT NULL,
|
||||
fsm_id UUID NOT NULL REFERENCES machines(id),
|
||||
event_id UUID NOT NULL REFERENCES events(id),
|
||||
content JSONB NOT NULL,
|
||||
status ActionStatus NOT NULL,
|
||||
error JSONB
|
||||
);
|
||||
|
||||
CREATE INDEX idx_actions_machines ON actions(fsm_id);
|
||||
CREATE INDEX idx_actions_events ON actions(event_id);
|
Loading…
Reference in a new issue