Files
coder/coderd/database/migrations/000003_workspaces.up.sql
Kyle Carberry 02ad3f14f5 chore: Rename Projects to Templates (#880)
Customer feedback indicated projects was a confusing name.
After querying the team internally, it seemed unanimous
that it is indeed a confusing name.

Here's for a lil less confusion @ashmeer7 🥂
2022-04-06 12:42:40 -05:00

24 lines
775 B
SQL

CREATE TABLE workspaces (
id uuid NOT NULL,
created_at timestamptz NOT NULL,
updated_at timestamptz NOT NULL,
-- Use ON DELETE RESTRICT so that we can cleanup external workspace
-- resources first.
owner_id uuid NOT NULL REFERENCES users (id) ON DELETE RESTRICT,
template_id uuid NOT NULL REFERENCES templates (id) ON DELETE RESTRICT,
deleted boolean NOT NULL DEFAULT FALSE,
name varchar(64) NOT NULL,
PRIMARY KEY (id)
);
-- Enforces no active workspaces have the same name.
CREATE UNIQUE INDEX ON workspaces USING btree (owner_id, name) WHERE deleted = FALSE;
CREATE UNIQUE INDEX idx_workspaces_name_lower ON workspaces USING btree (lower(name));
CREATE TYPE workspace_transition AS ENUM (
'start',
'stop',
'delete'
);