2022-03-17 18:10:46 -05:00
|
|
|
CREATE TABLE workspaces (
|
2022-04-01 14:42:36 -05:00
|
|
|
id uuid NOT NULL,
|
2022-01-25 13:52:58 -06:00
|
|
|
created_at timestamptz NOT NULL,
|
|
|
|
|
updated_at timestamptz NOT NULL,
|
2022-04-01 14:42:36 -05:00
|
|
|
-- Use ON DELETE RESTRICT so that we can cleanup external workspace
|
|
|
|
|
-- resources first.
|
|
|
|
|
owner_id uuid NOT NULL REFERENCES users (id) ON DELETE RESTRICT,
|
2022-04-25 16:11:03 -05:00
|
|
|
organization_id uuid NOT NULL REFERENCES organizations (id) ON DELETE RESTRICT,
|
2022-04-06 12:42:40 -05:00
|
|
|
template_id uuid NOT NULL REFERENCES templates (id) ON DELETE RESTRICT,
|
2022-03-22 13:17:50 -06:00
|
|
|
deleted boolean NOT NULL DEFAULT FALSE,
|
2022-04-01 14:42:36 -05:00
|
|
|
name varchar(64) NOT NULL,
|
|
|
|
|
PRIMARY KEY (id)
|
2022-01-25 13:52:58 -06:00
|
|
|
);
|
|
|
|
|
|
2022-03-22 13:17:50 -06:00
|
|
|
-- Enforces no active workspaces have the same name.
|
2022-04-24 21:40:14 -05:00
|
|
|
CREATE UNIQUE INDEX ON workspaces USING btree (owner_id, lower(name)) WHERE deleted = FALSE;
|
2022-03-22 13:17:50 -06:00
|
|
|
|
2022-01-25 13:52:58 -06:00
|
|
|
CREATE TYPE workspace_transition AS ENUM (
|
|
|
|
|
'start',
|
|
|
|
|
'stop',
|
|
|
|
|
'delete'
|
|
|
|
|
);
|
|
|
|
|
|