2022-03-25 21:07:45 +00:00
-- Code generated by 'make coderd/database/generate'. DO NOT EDIT.
2022-01-05 15:20:56 +00:00
2022-09-19 17:39:02 +00:00
CREATE TYPE api_key_scope AS ENUM (
' all ' ,
' application_connect '
) ;
2022-10-14 16:46:38 +00:00
CREATE TYPE app_sharing_level AS ENUM (
' owner ' ,
' authenticated ' ,
' public '
) ;
2022-05-02 19:30:46 +00:00
CREATE TYPE audit_action AS ENUM (
' create ' ,
' write ' ,
2022-10-25 19:34:48 +00:00
' delete ' ,
' start ' ,
' stop '
2022-05-02 19:30:46 +00:00
) ;
2022-06-17 17:41:11 +00:00
CREATE TYPE build_reason AS ENUM (
' initiator ' ,
' autostart ' ,
' autostop '
) ;
2022-01-25 19:52:58 +00:00
CREATE TYPE log_level AS ENUM (
' trace ' ,
' debug ' ,
' info ' ,
' warn ' ,
2022-02-01 05:36:15 +00:00
' error '
) ;
CREATE TYPE log_source AS ENUM (
' provisioner_daemon ' ,
' provisioner '
2022-01-25 19:52:58 +00:00
) ;
2022-01-12 18:04:11 +00:00
CREATE TYPE login_type AS ENUM (
2022-04-23 22:58:57 +00:00
' password ' ,
2022-08-01 04:05:35 +00:00
' github ' ,
2022-10-06 19:02:27 +00:00
' oidc ' ,
' token '
2022-01-12 18:04:11 +00:00
) ;
2022-01-29 23:38:32 +00:00
CREATE TYPE parameter_destination_scheme AS ENUM (
2022-02-04 19:36:43 +00:00
' none ' ,
2022-01-29 23:38:32 +00:00
' environment_variable ' ,
' provisioner_variable '
) ;
CREATE TYPE parameter_scope AS ENUM (
2022-04-06 17:42:40 +00:00
' template ' ,
2022-02-12 19:34:04 +00:00
' import_job ' ,
2022-01-29 23:38:32 +00:00
' workspace '
) ;
CREATE TYPE parameter_source_scheme AS ENUM (
2022-02-04 19:36:43 +00:00
' none ' ,
2022-01-29 23:38:32 +00:00
' data '
) ;
2022-01-24 17:07:42 +00:00
CREATE TYPE parameter_type_system AS ENUM (
2022-02-04 19:36:43 +00:00
' none ' ,
2022-01-24 17:07:42 +00:00
' hcl '
) ;
2022-01-29 23:38:32 +00:00
CREATE TYPE provisioner_job_type AS ENUM (
2022-04-06 17:42:40 +00:00
' template_version_import ' ,
2022-06-01 14:44:53 +00:00
' workspace_build ' ,
' template_version_dry_run '
2022-01-29 23:38:32 +00:00
) ;
2022-02-08 18:00:44 +00:00
CREATE TYPE provisioner_storage_method AS ENUM (
' file '
) ;
2022-01-24 17:07:42 +00:00
CREATE TYPE provisioner_type AS ENUM (
2022-02-04 22:51:54 +00:00
' echo ' ,
' terraform '
2022-01-24 17:07:42 +00:00
) ;
2022-05-02 19:30:46 +00:00
CREATE TYPE resource_type AS ENUM (
' organization ' ,
' template ' ,
' template_version ' ,
' user ' ,
2022-09-08 14:36:34 +00:00
' workspace ' ,
' git_ssh_key ' ,
2022-10-19 07:00:45 +00:00
' api_key ' ,
2022-10-25 19:34:48 +00:00
' group ' ,
' workspace_build '
2022-05-02 19:30:46 +00:00
) ;
2022-04-26 14:00:07 +00:00
CREATE TYPE user_status AS ENUM (
' active ' ,
' suspended '
) ;
2023-01-24 12:24:27 +00:00
CREATE TYPE workspace_agent_lifecycle_state AS ENUM (
' created ' ,
' starting ' ,
' start_timeout ' ,
' start_error ' ,
' ready '
) ;
2022-09-23 19:51:04 +00:00
CREATE TYPE workspace_app_health AS ENUM (
' disabled ' ,
' initializing ' ,
' healthy ' ,
' unhealthy '
) ;
2022-01-25 19:52:58 +00:00
CREATE TYPE workspace_transition AS ENUM (
' start ' ,
' stop ' ,
' delete '
) ;
2022-09-01 19:58:23 +00:00
CREATE TABLE agent_stats (
id uuid NOT NULL ,
created_at timestamp with time zone NOT NULL ,
user_id uuid NOT NULL ,
agent_id uuid NOT NULL ,
workspace_id uuid NOT NULL ,
template_id uuid NOT NULL ,
payload jsonb NOT NULL
) ;
2022-01-12 18:04:11 +00:00
CREATE TABLE api_keys (
id text NOT NULL ,
hashed_secret bytea NOT NULL ,
2022-04-01 19:42:36 +00:00
user_id uuid NOT NULL ,
2022-01-12 18:04:11 +00:00
last_used timestamp with time zone NOT NULL ,
expires_at timestamp with time zone NOT NULL ,
created_at timestamp with time zone NOT NULL ,
updated_at timestamp with time zone NOT NULL ,
login_type login_type NOT NULL ,
2022-06-22 17:32:21 +00:00
lifetime_seconds bigint DEFAULT 86400 NOT NULL ,
2022-09-19 17:39:02 +00:00
ip_address inet DEFAULT ' 0.0.0.0 ' : : inet NOT NULL ,
2022-11-04 08:15:17 +00:00
scope api_key_scope DEFAULT ' all ' : : api_key_scope NOT NULL
2022-01-12 18:04:11 +00:00
) ;
2022-09-22 22:30:32 +00:00
COMMENT ON COLUMN api_keys . hashed_secret IS ' hashed_secret contains a SHA256 hash of the key secret. This is considered a secret and MUST NOT be returned from the API as it is used for API key encryption in app proxying code. ' ;
2022-05-02 19:30:46 +00:00
CREATE TABLE audit_logs (
id uuid NOT NULL ,
" time " timestamp with time zone NOT NULL ,
user_id uuid NOT NULL ,
organization_id uuid NOT NULL ,
2022-11-22 18:22:56 +00:00
ip inet ,
user_agent character varying ( 256 ) ,
2022-05-02 19:30:46 +00:00
resource_type resource_type NOT NULL ,
resource_id uuid NOT NULL ,
resource_target text NOT NULL ,
action audit_action NOT NULL ,
diff jsonb NOT NULL ,
2022-08-31 21:12:54 +00:00
status_code integer NOT NULL ,
additional_fields jsonb NOT NULL ,
request_id uuid NOT NULL ,
resource_icon text NOT NULL
2022-05-02 19:30:46 +00:00
) ;
2022-03-17 23:10:46 +00:00
CREATE TABLE files (
2022-02-12 19:34:04 +00:00
hash character varying ( 64 ) NOT NULL ,
2022-02-07 21:32:37 +00:00
created_at timestamp with time zone NOT NULL ,
2022-04-01 19:42:36 +00:00
created_by uuid NOT NULL ,
2022-02-07 21:32:37 +00:00
mimetype character varying ( 64 ) NOT NULL ,
2022-10-13 23:02:52 +00:00
data bytea NOT NULL ,
id uuid DEFAULT gen_random_uuid ( ) NOT NULL
2022-02-07 21:32:37 +00:00
) ;
2022-10-25 00:46:24 +00:00
CREATE TABLE git_auth_links (
provider_id text NOT NULL ,
user_id uuid NOT NULL ,
created_at timestamp with time zone NOT NULL ,
updated_at timestamp with time zone NOT NULL ,
oauth_access_token text NOT NULL ,
oauth_refresh_token text NOT NULL ,
oauth_expiry timestamp with time zone NOT NULL
) ;
2022-04-06 00:18:26 +00:00
CREATE TABLE gitsshkeys (
user_id uuid NOT NULL ,
created_at timestamp with time zone NOT NULL ,
updated_at timestamp with time zone NOT NULL ,
private_key text NOT NULL ,
public_key text NOT NULL
) ;
2022-10-10 20:37:06 +00:00
CREATE TABLE group_members (
user_id uuid NOT NULL ,
group_id uuid NOT NULL
) ;
CREATE TABLE groups (
id uuid NOT NULL ,
name text NOT NULL ,
2022-10-17 22:46:01 +00:00
organization_id uuid NOT NULL ,
2022-11-14 17:57:33 +00:00
avatar_url text DEFAULT ' ' : : text NOT NULL ,
quota_allowance integer DEFAULT 0 NOT NULL
2022-10-10 20:37:06 +00:00
) ;
2022-01-12 18:04:11 +00:00
CREATE TABLE licenses (
id integer NOT NULL ,
2022-08-22 22:02:50 +00:00
uploaded_at timestamp with time zone NOT NULL ,
jwt text NOT NULL ,
2022-11-16 23:09:49 +00:00
exp timestamp with time zone NOT NULL ,
uuid uuid
2022-01-12 18:04:11 +00:00
) ;
2022-08-24 12:44:30 +00:00
COMMENT ON COLUMN licenses . exp IS ' exp tracks the claim of the same name in the JWT, and we include it here so that we can easily query for licenses that have not yet expired. ' ;
2022-04-01 19:42:36 +00:00
CREATE SEQUENCE licenses_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1 ;
2022-11-04 08:15:17 +00:00
ALTER SEQUENCE licenses_id_seq OWNED BY licenses . id ;
2022-04-01 19:42:36 +00:00
2022-01-12 18:04:11 +00:00
CREATE TABLE organization_members (
2022-04-01 19:42:36 +00:00
user_id uuid NOT NULL ,
organization_id uuid NOT NULL ,
2022-01-12 18:04:11 +00:00
created_at timestamp with time zone NOT NULL ,
updated_at timestamp with time zone NOT NULL ,
roles text [ ] DEFAULT ' {organization-member} ' : : text [ ] NOT NULL
) ;
CREATE TABLE organizations (
2022-04-01 19:42:36 +00:00
id uuid NOT NULL ,
2022-01-12 18:04:11 +00:00
name text NOT NULL ,
description text NOT NULL ,
created_at timestamp with time zone NOT NULL ,
2022-04-01 19:42:36 +00:00
updated_at timestamp with time zone NOT NULL
2022-01-12 18:04:11 +00:00
) ;
2022-03-17 23:10:46 +00:00
CREATE TABLE parameter_schemas (
2022-02-08 18:00:44 +00:00
id uuid NOT NULL ,
created_at timestamp with time zone NOT NULL ,
job_id uuid NOT NULL ,
name character varying ( 64 ) NOT NULL ,
description character varying ( 8192 ) DEFAULT ' ' : : character varying NOT NULL ,
2023-01-23 11:14:47 +00:00
default_source_scheme parameter_source_scheme NOT NULL ,
2022-02-12 19:34:04 +00:00
default_source_value text NOT NULL ,
2022-02-08 18:00:44 +00:00
allow_override_source boolean NOT NULL ,
2023-01-23 11:14:47 +00:00
default_destination_scheme parameter_destination_scheme NOT NULL ,
2022-02-08 18:00:44 +00:00
allow_override_destination boolean NOT NULL ,
default_refresh text NOT NULL ,
redisplay_value boolean NOT NULL ,
validation_error character varying ( 256 ) NOT NULL ,
validation_condition character varying ( 512 ) NOT NULL ,
validation_type_system parameter_type_system NOT NULL ,
2022-07-13 20:29:34 +00:00
validation_value_type character varying ( 64 ) NOT NULL ,
index integer NOT NULL
2022-02-08 18:00:44 +00:00
) ;
2022-03-17 23:10:46 +00:00
CREATE TABLE parameter_values (
2022-01-29 23:38:32 +00:00
id uuid NOT NULL ,
created_at timestamp with time zone NOT NULL ,
updated_at timestamp with time zone NOT NULL ,
scope parameter_scope NOT NULL ,
2022-04-01 19:42:36 +00:00
scope_id uuid NOT NULL ,
2022-03-07 17:40:54 +00:00
name character varying ( 64 ) NOT NULL ,
2022-01-29 23:38:32 +00:00
source_scheme parameter_source_scheme NOT NULL ,
source_value text NOT NULL ,
2022-02-12 19:34:04 +00:00
destination_scheme parameter_destination_scheme NOT NULL
2022-01-29 23:38:32 +00:00
) ;
2022-03-17 23:10:46 +00:00
CREATE TABLE provisioner_daemons (
2022-01-29 23:38:32 +00:00
id uuid NOT NULL ,
created_at timestamp with time zone NOT NULL ,
updated_at timestamp with time zone ,
name character varying ( 64 ) NOT NULL ,
2022-10-17 13:43:30 +00:00
provisioners provisioner_type [ ] NOT NULL ,
2022-11-16 22:34:06 +00:00
replica_id uuid ,
tags jsonb DEFAULT ' {} ' : : jsonb NOT NULL
2022-01-29 23:38:32 +00:00
) ;
2022-03-17 23:10:46 +00:00
CREATE TABLE provisioner_job_logs (
job_id uuid NOT NULL ,
created_at timestamp with time zone NOT NULL ,
source log_source NOT NULL ,
level log_level NOT NULL ,
2022-03-28 18:43:22 +00:00
stage character varying ( 128 ) NOT NULL ,
2022-11-07 02:50:34 +00:00
output character varying ( 1024 ) NOT NULL ,
id bigint NOT NULL
2022-03-17 23:10:46 +00:00
) ;
2022-11-07 02:50:34 +00:00
CREATE SEQUENCE provisioner_job_logs_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1 ;
ALTER SEQUENCE provisioner_job_logs_id_seq OWNED BY provisioner_job_logs . id ;
2022-03-17 23:10:46 +00:00
CREATE TABLE provisioner_jobs (
2022-01-29 23:38:32 +00:00
id uuid NOT NULL ,
created_at timestamp with time zone NOT NULL ,
updated_at timestamp with time zone NOT NULL ,
started_at timestamp with time zone ,
2022-03-22 19:17:50 +00:00
canceled_at timestamp with time zone ,
2022-01-29 23:38:32 +00:00
completed_at timestamp with time zone ,
error text ,
2022-04-01 19:42:36 +00:00
organization_id uuid NOT NULL ,
initiator_id uuid NOT NULL ,
2022-01-29 23:38:32 +00:00
provisioner provisioner_type NOT NULL ,
2022-02-08 18:00:44 +00:00
storage_method provisioner_storage_method NOT NULL ,
2022-01-29 23:38:32 +00:00
type provisioner_job_type NOT NULL ,
input jsonb NOT NULL ,
2022-10-13 23:02:52 +00:00
worker_id uuid ,
2022-11-16 22:34:06 +00:00
file_id uuid NOT NULL ,
tags jsonb DEFAULT ' {"scope": "organization"} ' : : jsonb NOT NULL
2022-01-29 23:38:32 +00:00
) ;
2022-10-17 13:43:30 +00:00
CREATE TABLE replicas (
id uuid NOT NULL ,
created_at timestamp with time zone NOT NULL ,
started_at timestamp with time zone NOT NULL ,
stopped_at timestamp with time zone ,
updated_at timestamp with time zone NOT NULL ,
hostname text NOT NULL ,
region_id integer NOT NULL ,
relay_address text NOT NULL ,
database_latency integer NOT NULL ,
version text NOT NULL ,
error text DEFAULT ' ' : : text NOT NULL
) ;
2022-06-17 05:26:40 +00:00
CREATE TABLE site_configs (
key character varying ( 256 ) NOT NULL ,
value character varying ( 8192 ) NOT NULL
) ;
2023-01-17 10:22:11 +00:00
CREATE TABLE template_version_parameters (
template_version_id uuid NOT NULL ,
name text NOT NULL ,
description text NOT NULL ,
type text NOT NULL ,
mutable boolean NOT NULL ,
default_value text NOT NULL ,
icon text NOT NULL ,
options jsonb DEFAULT ' [] ' : : jsonb NOT NULL ,
validation_regex text NOT NULL ,
validation_min integer NOT NULL ,
2023-01-24 13:22:00 +00:00
validation_max integer NOT NULL ,
validation_error text DEFAULT ' ' : : text NOT NULL
2023-01-17 10:22:11 +00:00
) ;
COMMENT ON COLUMN template_version_parameters . name IS ' Parameter name ' ;
COMMENT ON COLUMN template_version_parameters . description IS ' Parameter description ' ;
COMMENT ON COLUMN template_version_parameters . type IS ' Parameter type ' ;
COMMENT ON COLUMN template_version_parameters . mutable IS ' Is parameter mutable? ' ;
COMMENT ON COLUMN template_version_parameters . default_value IS ' Default value ' ;
COMMENT ON COLUMN template_version_parameters . icon IS ' Icon ' ;
COMMENT ON COLUMN template_version_parameters . options IS ' Additional options ' ;
COMMENT ON COLUMN template_version_parameters . validation_regex IS ' Validation: regex pattern ' ;
COMMENT ON COLUMN template_version_parameters . validation_min IS ' Validation: minimum length of value ' ;
COMMENT ON COLUMN template_version_parameters . validation_max IS ' Validation: maximum length of value ' ;
2023-01-24 13:22:00 +00:00
COMMENT ON COLUMN template_version_parameters . validation_error IS ' Validation: error displayed when the regex does not match. ' ;
2022-04-06 17:42:40 +00:00
CREATE TABLE template_versions (
id uuid NOT NULL ,
template_id uuid ,
organization_id uuid NOT NULL ,
created_at timestamp with time zone NOT NULL ,
updated_at timestamp with time zone NOT NULL ,
name character varying ( 64 ) NOT NULL ,
2022-05-17 20:00:48 +00:00
readme character varying ( 1048576 ) NOT NULL ,
2022-07-15 21:12:39 +00:00
job_id uuid NOT NULL ,
2022-10-31 16:38:07 +00:00
created_by uuid NOT NULL
2022-04-06 17:42:40 +00:00
) ;
CREATE TABLE templates (
id uuid NOT NULL ,
created_at timestamp with time zone NOT NULL ,
updated_at timestamp with time zone NOT NULL ,
organization_id uuid NOT NULL ,
deleted boolean DEFAULT false NOT NULL ,
name character varying ( 64 ) NOT NULL ,
provisioner provisioner_type NOT NULL ,
2022-05-16 20:56:11 +00:00
active_version_id uuid NOT NULL ,
2022-06-07 12:37:45 +00:00
description character varying ( 128 ) DEFAULT ' ' : : character varying NOT NULL ,
2022-11-09 19:36:25 +00:00
default_ttl bigint DEFAULT ' 604800000000000 ' : : bigint NOT NULL ,
2022-08-19 13:17:35 +00:00
created_by uuid NOT NULL ,
2022-10-10 20:37:06 +00:00
icon character varying ( 256 ) DEFAULT ' ' : : character varying NOT NULL ,
user_acl jsonb DEFAULT ' {} ' : : jsonb NOT NULL ,
2022-11-10 20:51:09 +00:00
group_acl jsonb DEFAULT ' {} ' : : jsonb NOT NULL ,
2022-11-21 10:43:53 +00:00
display_name character varying ( 64 ) DEFAULT ' ' : : character varying NOT NULL ,
allow_user_cancel_workspace_jobs boolean DEFAULT true NOT NULL
2022-04-06 17:42:40 +00:00
) ;
2022-11-09 19:36:25 +00:00
COMMENT ON COLUMN templates . default_ttl IS ' The default duration for auto-stop for workspaces created from this template. ' ;
2022-11-10 20:51:09 +00:00
COMMENT ON COLUMN templates . display_name IS ' Display name is a custom, human-friendly template name that user can set. ' ;
2022-11-21 10:43:53 +00:00
COMMENT ON COLUMN templates . allow_user_cancel_workspace_jobs IS ' Allow users to cancel in-progress workspace jobs. ' ;
2022-08-17 23:00:53 +00:00
CREATE TABLE user_links (
user_id uuid NOT NULL ,
login_type login_type NOT NULL ,
linked_id text DEFAULT ' ' : : text NOT NULL ,
oauth_access_token text DEFAULT ' ' : : text NOT NULL ,
oauth_refresh_token text DEFAULT ' ' : : text NOT NULL ,
oauth_expiry timestamp with time zone DEFAULT ' 0001-01-01 00:00:00+00 ' : : timestamp with time zone NOT NULL
) ;
2022-01-12 18:04:11 +00:00
CREATE TABLE users (
2022-04-01 19:42:36 +00:00
id uuid NOT NULL ,
2022-01-12 18:04:11 +00:00
email text NOT NULL ,
2022-04-25 01:08:26 +00:00
username text DEFAULT ' ' : : text NOT NULL ,
2022-01-12 18:04:11 +00:00
hashed_password bytea NOT NULL ,
created_at timestamp with time zone NOT NULL ,
2022-04-26 14:00:07 +00:00
updated_at timestamp with time zone NOT NULL ,
2022-11-04 08:15:17 +00:00
status user_status DEFAULT ' active ' : : user_status NOT NULL ,
2022-08-17 23:00:53 +00:00
rbac_roles text [ ] DEFAULT ' {} ' : : text [ ] NOT NULL ,
2022-11-04 08:15:17 +00:00
login_type login_type DEFAULT ' password ' : : login_type NOT NULL ,
2022-09-12 23:24:20 +00:00
avatar_url text ,
2022-09-26 15:31:03 +00:00
deleted boolean DEFAULT false NOT NULL ,
last_seen_at timestamp without time zone DEFAULT ' 0001-01-01 00:00:00 ' : : timestamp without time zone NOT NULL
2022-01-12 18:04:11 +00:00
) ;
2022-03-17 23:10:46 +00:00
CREATE TABLE workspace_agents (
2022-03-07 17:40:54 +00:00
id uuid NOT NULL ,
created_at timestamp with time zone NOT NULL ,
2022-03-22 19:17:50 +00:00
updated_at timestamp with time zone NOT NULL ,
2022-04-11 21:06:15 +00:00
name character varying ( 64 ) NOT NULL ,
2022-03-22 19:17:50 +00:00
first_connected_at timestamp with time zone ,
last_connected_at timestamp with time zone ,
disconnected_at timestamp with time zone ,
2022-03-07 17:40:54 +00:00
resource_id uuid NOT NULL ,
auth_token uuid NOT NULL ,
2022-07-28 20:52:03 +00:00
auth_instance_id character varying ,
2022-04-11 21:06:15 +00:00
architecture character varying ( 64 ) NOT NULL ,
2022-03-07 17:40:54 +00:00
environment_variables jsonb ,
2022-04-11 21:06:15 +00:00
operating_system character varying ( 64 ) NOT NULL ,
2022-03-07 17:40:54 +00:00
startup_script character varying ( 65534 ) ,
instance_metadata jsonb ,
2022-05-02 15:27:34 +00:00
resource_metadata jsonb ,
2022-06-24 15:25:01 +00:00
directory character varying ( 4096 ) DEFAULT ' ' : : character varying NOT NULL ,
2022-11-06 21:27:09 +00:00
version text DEFAULT ' ' : : text NOT NULL ,
2022-11-09 15:27:05 +00:00
last_connected_replica_id uuid ,
connection_timeout_seconds integer DEFAULT 0 NOT NULL ,
2022-11-24 12:22:20 +00:00
troubleshooting_url text DEFAULT ' ' : : text NOT NULL ,
2023-01-24 12:24:27 +00:00
motd_file text DEFAULT ' ' : : text NOT NULL ,
lifecycle_state workspace_agent_lifecycle_state DEFAULT ' created ' : : workspace_agent_lifecycle_state NOT NULL ,
2023-01-27 20:07:47 +00:00
login_before_ready boolean DEFAULT true NOT NULL ,
2023-01-24 12:24:27 +00:00
startup_script_timeout_seconds integer DEFAULT 0 NOT NULL
2022-03-07 17:40:54 +00:00
) ;
2022-08-31 15:33:50 +00:00
COMMENT ON COLUMN workspace_agents . version IS ' Version tracks the version of the currently running workspace agent. Workspace agents register their version upon start. ' ;
2022-11-09 15:27:05 +00:00
COMMENT ON COLUMN workspace_agents . connection_timeout_seconds IS ' Connection timeout in seconds, 0 means disabled. ' ;
COMMENT ON COLUMN workspace_agents . troubleshooting_url IS ' URL for troubleshooting the agent. ' ;
2022-11-24 12:22:20 +00:00
COMMENT ON COLUMN workspace_agents . motd_file IS ' Path to file inside workspace containing the message of the day (MOTD) to show to the user when logging in via SSH. ' ;
2023-01-24 12:24:27 +00:00
COMMENT ON COLUMN workspace_agents . lifecycle_state IS ' The current lifecycle state reported by the workspace agent. ' ;
2023-01-27 20:07:47 +00:00
COMMENT ON COLUMN workspace_agents . login_before_ready IS ' If true, the agent will not prevent login before it is ready (e.g. startup script is still executing). ' ;
2023-01-24 12:24:27 +00:00
COMMENT ON COLUMN workspace_agents . startup_script_timeout_seconds IS ' The number of seconds to wait for the startup script to complete. If the script does not complete within this time, the agent lifecycle will be marked as start_timeout. ' ;
2022-06-04 20:13:37 +00:00
CREATE TABLE workspace_apps (
id uuid NOT NULL ,
created_at timestamp with time zone NOT NULL ,
agent_id uuid NOT NULL ,
2022-10-28 17:41:31 +00:00
display_name character varying ( 64 ) NOT NULL ,
2022-06-04 20:13:37 +00:00
icon character varying ( 256 ) NOT NULL ,
command character varying ( 65534 ) ,
url character varying ( 65534 ) ,
2022-09-23 19:51:04 +00:00
healthcheck_url text DEFAULT ' ' : : text NOT NULL ,
healthcheck_interval integer DEFAULT 0 NOT NULL ,
healthcheck_threshold integer DEFAULT 0 NOT NULL ,
2022-11-04 08:15:17 +00:00
health workspace_app_health DEFAULT ' disabled ' : : workspace_app_health NOT NULL ,
2022-10-14 16:46:38 +00:00
subdomain boolean DEFAULT false NOT NULL ,
2022-11-04 08:15:17 +00:00
sharing_level app_sharing_level DEFAULT ' owner ' : : app_sharing_level NOT NULL ,
2022-12-14 21:54:18 +00:00
slug text NOT NULL ,
external boolean DEFAULT false NOT NULL
2022-06-04 20:13:37 +00:00
) ;
2023-01-17 10:22:11 +00:00
CREATE TABLE workspace_build_parameters (
workspace_build_id uuid NOT NULL ,
name text NOT NULL ,
value text NOT NULL
) ;
COMMENT ON COLUMN workspace_build_parameters . name IS ' Parameter name ' ;
COMMENT ON COLUMN workspace_build_parameters . value IS ' Parameter value ' ;
2022-03-17 23:10:46 +00:00
CREATE TABLE workspace_builds (
2022-01-25 19:52:58 +00:00
id uuid NOT NULL ,
created_at timestamp with time zone NOT NULL ,
updated_at timestamp with time zone NOT NULL ,
workspace_id uuid NOT NULL ,
2022-04-06 17:42:40 +00:00
template_version_id uuid NOT NULL ,
2022-05-18 16:33:33 +00:00
build_number integer NOT NULL ,
2022-01-25 19:52:58 +00:00
transition workspace_transition NOT NULL ,
2022-04-01 19:42:36 +00:00
initiator_id uuid NOT NULL ,
2022-01-25 19:52:58 +00:00
provisioner_state bytea ,
2022-05-26 17:08:11 +00:00
job_id uuid NOT NULL ,
2022-06-17 17:41:11 +00:00
deadline timestamp with time zone DEFAULT ' 0001-01-01 00:00:00+00 ' : : timestamp with time zone NOT NULL ,
2022-11-14 17:57:33 +00:00
reason build_reason DEFAULT ' initiator ' : : build_reason NOT NULL ,
daily_cost integer DEFAULT 0 NOT NULL
2022-03-07 17:40:54 +00:00
) ;
2022-08-01 21:53:05 +00:00
CREATE TABLE workspace_resource_metadata (
workspace_resource_id uuid NOT NULL ,
key character varying ( 1024 ) NOT NULL ,
value character varying ( 65536 ) ,
2022-12-14 19:08:22 +00:00
sensitive boolean NOT NULL ,
id bigint NOT NULL
2022-08-01 21:53:05 +00:00
) ;
2022-12-14 19:08:22 +00:00
CREATE SEQUENCE workspace_resource_metadata_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1 ;
ALTER SEQUENCE workspace_resource_metadata_id_seq OWNED BY workspace_resource_metadata . id ;
2022-03-17 23:10:46 +00:00
CREATE TABLE workspace_resources (
2022-03-07 17:40:54 +00:00
id uuid NOT NULL ,
created_at timestamp with time zone NOT NULL ,
job_id uuid NOT NULL ,
transition workspace_transition NOT NULL ,
2022-03-22 19:17:50 +00:00
type character varying ( 192 ) NOT NULL ,
2022-09-09 19:38:00 +00:00
name character varying ( 64 ) NOT NULL ,
2022-09-13 14:32:59 +00:00
hide boolean DEFAULT false NOT NULL ,
2022-11-01 21:51:57 +00:00
icon character varying ( 256 ) DEFAULT ' ' : : character varying NOT NULL ,
2022-11-14 17:57:33 +00:00
instance_type character varying ( 256 ) ,
daily_cost integer DEFAULT 0 NOT NULL
2022-01-25 19:52:58 +00:00
) ;
2022-03-17 23:10:46 +00:00
CREATE TABLE workspaces (
id uuid NOT NULL ,
created_at timestamp with time zone NOT NULL ,
updated_at timestamp with time zone NOT NULL ,
2022-04-01 19:42:36 +00:00
owner_id uuid NOT NULL ,
2022-04-25 21:11:03 +00:00
organization_id uuid NOT NULL ,
2022-04-06 17:42:40 +00:00
template_id uuid NOT NULL ,
2022-03-22 19:17:50 +00:00
deleted boolean DEFAULT false NOT NULL ,
2022-04-07 09:03:35 +00:00
name character varying ( 64 ) NOT NULL ,
autostart_schedule text ,
2022-09-02 00:08:51 +00:00
ttl bigint ,
last_used_at timestamp without time zone DEFAULT ' 0001-01-01 00:00:00 ' : : timestamp without time zone NOT NULL
2022-03-17 23:10:46 +00:00
) ;
2022-11-04 08:15:17 +00:00
ALTER TABLE ONLY licenses ALTER COLUMN id SET DEFAULT nextval ( ' licenses_id_seq ' : : regclass ) ;
2022-04-01 19:42:36 +00:00
2022-11-07 02:50:34 +00:00
ALTER TABLE ONLY provisioner_job_logs ALTER COLUMN id SET DEFAULT nextval ( ' provisioner_job_logs_id_seq ' : : regclass ) ;
2022-12-14 19:08:22 +00:00
ALTER TABLE ONLY workspace_resource_metadata ALTER COLUMN id SET DEFAULT nextval ( ' workspace_resource_metadata_id_seq ' : : regclass ) ;
2022-09-01 19:58:23 +00:00
ALTER TABLE ONLY agent_stats
ADD CONSTRAINT agent_stats_pkey PRIMARY KEY ( id ) ;
2022-04-01 19:42:36 +00:00
ALTER TABLE ONLY api_keys
ADD CONSTRAINT api_keys_pkey PRIMARY KEY ( id ) ;
2022-05-02 19:30:46 +00:00
ALTER TABLE ONLY audit_logs
ADD CONSTRAINT audit_logs_pkey PRIMARY KEY ( id ) ;
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY files
2022-10-13 23:02:52 +00:00
ADD CONSTRAINT files_hash_created_by_key UNIQUE ( hash , created_by ) ;
ALTER TABLE ONLY files
ADD CONSTRAINT files_pkey PRIMARY KEY ( id ) ;
2022-02-07 21:32:37 +00:00
2022-10-25 00:46:24 +00:00
ALTER TABLE ONLY git_auth_links
ADD CONSTRAINT git_auth_links_provider_id_user_id_key UNIQUE ( provider_id , user_id ) ;
2022-04-06 00:18:26 +00:00
ALTER TABLE ONLY gitsshkeys
ADD CONSTRAINT gitsshkeys_pkey PRIMARY KEY ( user_id ) ;
2022-10-10 20:37:06 +00:00
ALTER TABLE ONLY group_members
ADD CONSTRAINT group_members_user_id_group_id_key UNIQUE ( user_id , group_id ) ;
ALTER TABLE ONLY groups
ADD CONSTRAINT groups_name_organization_id_key UNIQUE ( name , organization_id ) ;
ALTER TABLE ONLY groups
ADD CONSTRAINT groups_pkey PRIMARY KEY ( id ) ;
2022-08-22 22:02:50 +00:00
ALTER TABLE ONLY licenses
ADD CONSTRAINT licenses_jwt_key UNIQUE ( jwt ) ;
2022-04-01 19:42:36 +00:00
ALTER TABLE ONLY licenses
ADD CONSTRAINT licenses_pkey PRIMARY KEY ( id ) ;
ALTER TABLE ONLY organization_members
ADD CONSTRAINT organization_members_pkey PRIMARY KEY ( organization_id , user_id ) ;
ALTER TABLE ONLY organizations
ADD CONSTRAINT organizations_pkey PRIMARY KEY ( id ) ;
2022-02-08 18:00:44 +00:00
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY parameter_schemas
ADD CONSTRAINT parameter_schemas_job_id_name_key UNIQUE ( job_id , name ) ;
2022-02-08 18:00:44 +00:00
2022-04-01 19:42:36 +00:00
ALTER TABLE ONLY parameter_schemas
ADD CONSTRAINT parameter_schemas_pkey PRIMARY KEY ( id ) ;
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY parameter_values
2022-04-01 19:42:36 +00:00
ADD CONSTRAINT parameter_values_pkey PRIMARY KEY ( id ) ;
2022-01-29 23:38:32 +00:00
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY parameter_values
ADD CONSTRAINT parameter_values_scope_id_name_key UNIQUE ( scope_id , name ) ;
2022-01-29 23:38:32 +00:00
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY provisioner_daemons
2022-04-01 19:42:36 +00:00
ADD CONSTRAINT provisioner_daemons_name_key UNIQUE ( name ) ;
2022-01-29 23:38:32 +00:00
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY provisioner_daemons
2022-04-01 19:42:36 +00:00
ADD CONSTRAINT provisioner_daemons_pkey PRIMARY KEY ( id ) ;
2022-01-29 23:38:32 +00:00
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY provisioner_job_logs
2022-04-01 19:42:36 +00:00
ADD CONSTRAINT provisioner_job_logs_pkey PRIMARY KEY ( id ) ;
2022-01-29 23:38:32 +00:00
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY provisioner_jobs
2022-04-01 19:42:36 +00:00
ADD CONSTRAINT provisioner_jobs_pkey PRIMARY KEY ( id ) ;
2022-06-17 05:26:40 +00:00
ALTER TABLE ONLY site_configs
ADD CONSTRAINT site_configs_key_key UNIQUE ( key ) ;
2023-01-17 10:22:11 +00:00
ALTER TABLE ONLY template_version_parameters
ADD CONSTRAINT template_version_parameters_template_version_id_name_key UNIQUE ( template_version_id , name ) ;
2022-04-06 17:42:40 +00:00
ALTER TABLE ONLY template_versions
ADD CONSTRAINT template_versions_pkey PRIMARY KEY ( id ) ;
ALTER TABLE ONLY template_versions
ADD CONSTRAINT template_versions_template_id_name_key UNIQUE ( template_id , name ) ;
ALTER TABLE ONLY templates
ADD CONSTRAINT templates_pkey PRIMARY KEY ( id ) ;
2022-08-17 23:00:53 +00:00
ALTER TABLE ONLY user_links
ADD CONSTRAINT user_links_pkey PRIMARY KEY ( user_id , login_type ) ;
2022-04-01 19:42:36 +00:00
ALTER TABLE ONLY users
ADD CONSTRAINT users_pkey PRIMARY KEY ( id ) ;
2022-02-07 21:32:37 +00:00
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY workspace_agents
2022-04-01 19:42:36 +00:00
ADD CONSTRAINT workspace_agents_pkey PRIMARY KEY ( id ) ;
2022-01-25 19:52:58 +00:00
2022-06-04 20:13:37 +00:00
ALTER TABLE ONLY workspace_apps
2022-10-28 17:41:31 +00:00
ADD CONSTRAINT workspace_apps_agent_id_slug_idx UNIQUE ( agent_id , slug ) ;
2022-06-04 20:13:37 +00:00
ALTER TABLE ONLY workspace_apps
ADD CONSTRAINT workspace_apps_pkey PRIMARY KEY ( id ) ;
2023-01-17 10:22:11 +00:00
ALTER TABLE ONLY workspace_build_parameters
ADD CONSTRAINT workspace_build_parameters_workspace_build_id_name_key UNIQUE ( workspace_build_id , name ) ;
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY workspace_builds
2022-04-01 19:42:36 +00:00
ADD CONSTRAINT workspace_builds_job_id_key UNIQUE ( job_id ) ;
2022-03-07 17:40:54 +00:00
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY workspace_builds
2022-04-01 19:42:36 +00:00
ADD CONSTRAINT workspace_builds_pkey PRIMARY KEY ( id ) ;
2022-03-07 17:40:54 +00:00
2022-05-18 16:33:33 +00:00
ALTER TABLE ONLY workspace_builds
ADD CONSTRAINT workspace_builds_workspace_id_build_number_key UNIQUE ( workspace_id , build_number ) ;
2022-08-01 21:53:05 +00:00
ALTER TABLE ONLY workspace_resource_metadata
2022-12-14 19:08:22 +00:00
ADD CONSTRAINT workspace_resource_metadata_name UNIQUE ( workspace_resource_id , key ) ;
ALTER TABLE ONLY workspace_resource_metadata
ADD CONSTRAINT workspace_resource_metadata_pkey PRIMARY KEY ( id ) ;
2022-08-01 21:53:05 +00:00
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY workspace_resources
2022-04-01 19:42:36 +00:00
ADD CONSTRAINT workspace_resources_pkey PRIMARY KEY ( id ) ;
2022-01-25 19:52:58 +00:00
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY workspaces
2022-04-01 19:42:36 +00:00
ADD CONSTRAINT workspaces_pkey PRIMARY KEY ( id ) ;
2022-09-01 19:58:23 +00:00
CREATE INDEX idx_agent_stats_created_at ON agent_stats USING btree ( created_at ) ;
CREATE INDEX idx_agent_stats_user_id ON agent_stats USING btree ( user_id ) ;
2022-04-01 19:42:36 +00:00
CREATE INDEX idx_api_keys_user ON api_keys USING btree ( user_id ) ;
2022-05-02 19:30:46 +00:00
CREATE INDEX idx_audit_log_organization_id ON audit_logs USING btree ( organization_id ) ;
CREATE INDEX idx_audit_log_resource_id ON audit_logs USING btree ( resource_id ) ;
CREATE INDEX idx_audit_log_user_id ON audit_logs USING btree ( user_id ) ;
CREATE INDEX idx_audit_logs_time_desc ON audit_logs USING btree ( " time " DESC ) ;
2022-04-01 19:42:36 +00:00
CREATE INDEX idx_organization_member_organization_id_uuid ON organization_members USING btree ( organization_id ) ;
CREATE INDEX idx_organization_member_user_id_uuid ON organization_members USING btree ( user_id ) ;
CREATE UNIQUE INDEX idx_organization_name ON organizations USING btree ( name ) ;
CREATE UNIQUE INDEX idx_organization_name_lower ON organizations USING btree ( lower ( name ) ) ;
2022-09-12 23:24:20 +00:00
CREATE UNIQUE INDEX idx_users_email ON users USING btree ( email ) WHERE ( deleted = false ) ;
2022-04-01 19:42:36 +00:00
2022-09-12 23:24:20 +00:00
CREATE UNIQUE INDEX idx_users_username ON users USING btree ( username ) WHERE ( deleted = false ) ;
2022-02-01 05:36:15 +00:00
2022-11-16 20:32:29 +00:00
CREATE INDEX provisioner_job_logs_id_job_id_idx ON provisioner_job_logs USING btree ( job_id , id ) ;
2022-12-02 01:29:15 +00:00
CREATE INDEX provisioner_jobs_started_at_idx ON provisioner_jobs USING btree ( started_at ) WHERE ( started_at IS NULL ) ;
2022-06-17 19:18:07 +00:00
CREATE UNIQUE INDEX templates_organization_id_name_idx ON templates USING btree ( organization_id , lower ( ( name ) : : text ) ) WHERE ( deleted = false ) ;
2022-03-22 19:17:50 +00:00
2022-09-27 03:51:58 +00:00
CREATE UNIQUE INDEX users_email_lower_idx ON users USING btree ( lower ( email ) ) WHERE ( deleted = false ) ;
2022-09-12 23:24:20 +00:00
CREATE UNIQUE INDEX users_username_lower_idx ON users USING btree ( lower ( username ) ) WHERE ( deleted = false ) ;
2022-04-01 19:42:36 +00:00
2022-12-02 01:29:05 +00:00
CREATE INDEX workspace_agents_auth_token_idx ON workspace_agents USING btree ( auth_token ) ;
2022-11-16 20:40:57 +00:00
CREATE INDEX workspace_agents_resource_id_idx ON workspace_agents USING btree ( resource_id ) ;
2022-11-10 20:09:44 +00:00
CREATE INDEX workspace_resources_job_id_idx ON workspace_resources USING btree ( job_id ) ;
2022-04-25 02:40:14 +00:00
CREATE UNIQUE INDEX workspaces_owner_id_lower_idx ON workspaces USING btree ( owner_id , lower ( ( name ) : : text ) ) WHERE ( deleted = false ) ;
2022-03-07 17:40:54 +00:00
2022-04-01 19:42:36 +00:00
ALTER TABLE ONLY api_keys
ADD CONSTRAINT api_keys_user_id_uuid_fkey FOREIGN KEY ( user_id ) REFERENCES users ( id ) ON DELETE CASCADE ;
2022-04-06 00:18:26 +00:00
ALTER TABLE ONLY gitsshkeys
ADD CONSTRAINT gitsshkeys_user_id_fkey FOREIGN KEY ( user_id ) REFERENCES users ( id ) ;
2022-10-10 20:37:06 +00:00
ALTER TABLE ONLY group_members
ADD CONSTRAINT group_members_group_id_fkey FOREIGN KEY ( group_id ) REFERENCES groups ( id ) ON DELETE CASCADE ;
ALTER TABLE ONLY group_members
ADD CONSTRAINT group_members_user_id_fkey FOREIGN KEY ( user_id ) REFERENCES users ( id ) ON DELETE CASCADE ;
ALTER TABLE ONLY groups
ADD CONSTRAINT groups_organization_id_fkey FOREIGN KEY ( organization_id ) REFERENCES organizations ( id ) ON DELETE CASCADE ;
2022-04-01 19:42:36 +00:00
ALTER TABLE ONLY organization_members
ADD CONSTRAINT organization_members_organization_id_uuid_fkey FOREIGN KEY ( organization_id ) REFERENCES organizations ( id ) ON DELETE CASCADE ;
ALTER TABLE ONLY organization_members
ADD CONSTRAINT organization_members_user_id_uuid_fkey FOREIGN KEY ( user_id ) REFERENCES users ( id ) ON DELETE CASCADE ;
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY parameter_schemas
ADD CONSTRAINT parameter_schemas_job_id_fkey FOREIGN KEY ( job_id ) REFERENCES provisioner_jobs ( id ) ON DELETE CASCADE ;
2022-02-06 00:24:51 +00:00
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY provisioner_job_logs
ADD CONSTRAINT provisioner_job_logs_job_id_fkey FOREIGN KEY ( job_id ) REFERENCES provisioner_jobs ( id ) ON DELETE CASCADE ;
2022-01-29 23:38:32 +00:00
2022-04-01 19:42:36 +00:00
ALTER TABLE ONLY provisioner_jobs
ADD CONSTRAINT provisioner_jobs_organization_id_fkey FOREIGN KEY ( organization_id ) REFERENCES organizations ( id ) ON DELETE CASCADE ;
2023-01-17 10:22:11 +00:00
ALTER TABLE ONLY template_version_parameters
ADD CONSTRAINT template_version_parameters_template_version_id_fkey FOREIGN KEY ( template_version_id ) REFERENCES template_versions ( id ) ON DELETE CASCADE ;
2022-07-15 21:12:39 +00:00
ALTER TABLE ONLY template_versions
ADD CONSTRAINT template_versions_created_by_fkey FOREIGN KEY ( created_by ) REFERENCES users ( id ) ON DELETE RESTRICT ;
2022-04-06 17:42:40 +00:00
ALTER TABLE ONLY template_versions
ADD CONSTRAINT template_versions_organization_id_fkey FOREIGN KEY ( organization_id ) REFERENCES organizations ( id ) ON DELETE CASCADE ;
ALTER TABLE ONLY template_versions
ADD CONSTRAINT template_versions_template_id_fkey FOREIGN KEY ( template_id ) REFERENCES templates ( id ) ON DELETE CASCADE ;
2022-06-10 19:24:21 +00:00
ALTER TABLE ONLY templates
ADD CONSTRAINT templates_created_by_fkey FOREIGN KEY ( created_by ) REFERENCES users ( id ) ON DELETE RESTRICT ;
2022-04-06 17:42:40 +00:00
ALTER TABLE ONLY templates
ADD CONSTRAINT templates_organization_id_fkey FOREIGN KEY ( organization_id ) REFERENCES organizations ( id ) ON DELETE CASCADE ;
2022-08-17 23:00:53 +00:00
ALTER TABLE ONLY user_links
ADD CONSTRAINT user_links_user_id_fkey FOREIGN KEY ( user_id ) REFERENCES users ( id ) ON DELETE CASCADE ;
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY workspace_agents
ADD CONSTRAINT workspace_agents_resource_id_fkey FOREIGN KEY ( resource_id ) REFERENCES workspace_resources ( id ) ON DELETE CASCADE ;
2022-03-07 17:40:54 +00:00
2022-06-04 20:13:37 +00:00
ALTER TABLE ONLY workspace_apps
ADD CONSTRAINT workspace_apps_agent_id_fkey FOREIGN KEY ( agent_id ) REFERENCES workspace_agents ( id ) ON DELETE CASCADE ;
2023-01-17 10:22:11 +00:00
ALTER TABLE ONLY workspace_build_parameters
ADD CONSTRAINT workspace_build_parameters_workspace_build_id_fkey FOREIGN KEY ( workspace_build_id ) REFERENCES workspace_builds ( id ) ON DELETE CASCADE ;
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY workspace_builds
ADD CONSTRAINT workspace_builds_job_id_fkey FOREIGN KEY ( job_id ) REFERENCES provisioner_jobs ( id ) ON DELETE CASCADE ;
2022-01-25 19:52:58 +00:00
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY workspace_builds
2022-04-06 17:42:40 +00:00
ADD CONSTRAINT workspace_builds_template_version_id_fkey FOREIGN KEY ( template_version_id ) REFERENCES template_versions ( id ) ON DELETE CASCADE ;
2022-01-25 19:52:58 +00:00
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY workspace_builds
ADD CONSTRAINT workspace_builds_workspace_id_fkey FOREIGN KEY ( workspace_id ) REFERENCES workspaces ( id ) ON DELETE CASCADE ;
2022-01-25 19:52:58 +00:00
2022-08-01 21:53:05 +00:00
ALTER TABLE ONLY workspace_resource_metadata
ADD CONSTRAINT workspace_resource_metadata_workspace_resource_id_fkey FOREIGN KEY ( workspace_resource_id ) REFERENCES workspace_resources ( id ) ON DELETE CASCADE ;
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY workspace_resources
ADD CONSTRAINT workspace_resources_job_id_fkey FOREIGN KEY ( job_id ) REFERENCES provisioner_jobs ( id ) ON DELETE CASCADE ;
2022-01-25 19:52:58 +00:00
2022-04-25 21:11:03 +00:00
ALTER TABLE ONLY workspaces
ADD CONSTRAINT workspaces_organization_id_fkey FOREIGN KEY ( organization_id ) REFERENCES organizations ( id ) ON DELETE RESTRICT ;
2022-03-17 23:10:46 +00:00
ALTER TABLE ONLY workspaces
2022-04-01 19:42:36 +00:00
ADD CONSTRAINT workspaces_owner_id_fkey FOREIGN KEY ( owner_id ) REFERENCES users ( id ) ON DELETE RESTRICT ;
ALTER TABLE ONLY workspaces
2022-04-06 17:42:40 +00:00
ADD CONSTRAINT workspaces_template_id_fkey FOREIGN KEY ( template_id ) REFERENCES templates ( id ) ON DELETE RESTRICT ;
2022-05-19 22:37:22 +00:00