Files
coder/database/dump.sql
T
Kyle Carberry a44056cff5 feat: Add project API endpoints (#51)
* feat: Add project models

* Add project query functions

* Add organization parameter query

* Add project URL parameter parse

* Add project create and list endpoints

* Add test for organization provided

* Remove unimplemented routes

* Decrease conn timeout

* Add test for UnbiasedModulo32

* Fix expected value

* Add single user endpoint

* Add query for project versions

* Fix linting errors

* Add comments

* Add test for invalid archive

* Check unauthenticated endpoints

* Add check if no change happened

* Ensure context close ends listener

* Fix parallel test run

* Test empty

* Fix organization param comment
2022-01-24 17:07:42 +00:00

159 lines
5.2 KiB
SQL

-- Code generated by 'make database/generate'. DO NOT EDIT.
CREATE TYPE login_type AS ENUM (
'built-in',
'saml',
'oidc'
);
CREATE TYPE parameter_type_system AS ENUM (
'hcl'
);
CREATE TYPE project_storage_method AS ENUM (
'inline-archive'
);
CREATE TYPE provisioner_type AS ENUM (
'terraform',
'cdr-basic'
);
CREATE TYPE userstatus AS ENUM (
'active',
'dormant',
'decommissioned'
);
CREATE TABLE api_keys (
id text NOT NULL,
hashed_secret bytea NOT NULL,
user_id text NOT NULL,
application boolean NOT NULL,
name text NOT NULL,
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,
oidc_access_token text DEFAULT ''::text NOT NULL,
oidc_refresh_token text DEFAULT ''::text NOT NULL,
oidc_id_token text DEFAULT ''::text NOT NULL,
oidc_expiry timestamp with time zone DEFAULT '0001-01-01 00:00:00+00'::timestamp with time zone NOT NULL,
devurl_token boolean DEFAULT false NOT NULL
);
CREATE TABLE licenses (
id integer NOT NULL,
license jsonb NOT NULL,
created_at timestamp with time zone NOT NULL
);
CREATE TABLE organization_members (
organization_id text NOT NULL,
user_id text NOT NULL,
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 (
id text NOT NULL,
name text NOT NULL,
description text NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
"default" boolean DEFAULT false NOT NULL,
auto_off_threshold bigint DEFAULT '28800000000000'::bigint NOT NULL,
cpu_provisioning_rate real DEFAULT 4.0 NOT NULL,
memory_provisioning_rate real DEFAULT 1.0 NOT NULL,
workspace_auto_off boolean DEFAULT false NOT NULL
);
CREATE TABLE project (
id uuid NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
organization_id text NOT NULL,
name character varying(64) NOT NULL,
provisioner provisioner_type NOT NULL,
active_version_id uuid
);
CREATE TABLE project_history (
id uuid NOT NULL,
project_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,
description character varying(1048576) NOT NULL,
storage_method project_storage_method NOT NULL,
storage_source bytea NOT NULL,
import_job_id uuid NOT NULL
);
CREATE TABLE project_parameter (
id uuid NOT NULL,
created_at timestamp with time zone NOT NULL,
project_history_id uuid NOT NULL,
name character varying(64) NOT NULL,
description character varying(8192) DEFAULT ''::character varying NOT NULL,
default_source text,
allow_override_source boolean NOT NULL,
default_destination text,
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,
validation_value_type character varying(64) NOT NULL
);
CREATE TABLE users (
id text NOT NULL,
email text NOT NULL,
name text NOT NULL,
revoked boolean NOT NULL,
login_type login_type NOT NULL,
hashed_password bytea NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
temporary_password boolean DEFAULT false NOT NULL,
avatar_hash text DEFAULT ''::text NOT NULL,
ssh_key_regenerated_at timestamp with time zone DEFAULT now() NOT NULL,
username text DEFAULT ''::text NOT NULL,
dotfiles_git_uri text DEFAULT ''::text NOT NULL,
roles text[] DEFAULT '{site-member}'::text[] NOT NULL,
status userstatus DEFAULT 'active'::public.userstatus NOT NULL,
relatime timestamp with time zone DEFAULT now() NOT NULL,
gpg_key_regenerated_at timestamp with time zone DEFAULT now() NOT NULL,
_decomissioned boolean DEFAULT false NOT NULL,
shell text DEFAULT ''::text NOT NULL
);
ALTER TABLE ONLY project_history
ADD CONSTRAINT project_history_id_key UNIQUE (id);
ALTER TABLE ONLY project_history
ADD CONSTRAINT project_history_project_id_name_key UNIQUE (project_id, name);
ALTER TABLE ONLY project
ADD CONSTRAINT project_id_key UNIQUE (id);
ALTER TABLE ONLY project
ADD CONSTRAINT project_organization_id_name_key UNIQUE (organization_id, name);
ALTER TABLE ONLY project_parameter
ADD CONSTRAINT project_parameter_id_key UNIQUE (id);
ALTER TABLE ONLY project_parameter
ADD CONSTRAINT project_parameter_project_history_id_name_key UNIQUE (project_history_id, name);
ALTER TABLE ONLY project_history
ADD CONSTRAINT project_history_project_id_fkey FOREIGN KEY (project_id) REFERENCES project(id);
ALTER TABLE ONLY project_parameter
ADD CONSTRAINT project_parameter_project_history_id_fkey FOREIGN KEY (project_history_id) REFERENCES project_history(id) ON DELETE CASCADE;