mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: update v1 schema (#643)
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
-- Store arbitrary data like project source code or avatars.
|
||||
CREATE TABLE files (
|
||||
hash varchar(64) NOT NULL UNIQUE,
|
||||
hash varchar(64) NOT NULL,
|
||||
created_at timestamptz NOT NULL,
|
||||
created_by text NOT NULL,
|
||||
-- foreign key?
|
||||
created_by uuid NOT NULL,
|
||||
mimetype varchar(64) NOT NULL,
|
||||
data bytea NOT NULL
|
||||
data bytea NOT NULL,
|
||||
PRIMARY KEY (hash)
|
||||
);
|
||||
|
||||
CREATE TYPE provisioner_type AS ENUM ('echo', 'terraform');
|
||||
@@ -12,17 +14,18 @@ CREATE TYPE provisioner_type AS ENUM ('echo', 'terraform');
|
||||
-- Project defines infrastructure that your software project
|
||||
-- requires for development.
|
||||
CREATE TABLE projects (
|
||||
id uuid NOT NULL UNIQUE,
|
||||
id uuid NOT NULL,
|
||||
created_at timestamptz NOT NULL,
|
||||
updated_at timestamptz NOT NULL,
|
||||
-- Projects must be scoped to an organization.
|
||||
organization_id text NOT NULL,
|
||||
organization_id uuid NOT NULL REFERENCES organizations (id) ON DELETE CASCADE,
|
||||
deleted boolean NOT NULL DEFAULT FALSE,
|
||||
name varchar(64) NOT NULL,
|
||||
provisioner provisioner_type NOT NULL,
|
||||
-- Target's a Project Version to use for Workspaces.
|
||||
-- If a Workspace doesn't match this version, it will be prompted to rebuild.
|
||||
active_version_id uuid NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
-- Disallow projects to have the same name under
|
||||
-- the same organization.
|
||||
UNIQUE(organization_id, name)
|
||||
@@ -35,10 +38,10 @@ CREATE UNIQUE INDEX ON projects (organization_id, name) WHERE deleted = FALSE;
|
||||
-- an "import" job is queued to parse parameters. A Project Version
|
||||
-- can only be used if the import job succeeds.
|
||||
CREATE TABLE project_versions (
|
||||
id uuid NOT NULL UNIQUE,
|
||||
-- This should be indexed.
|
||||
project_id uuid REFERENCES projects (id),
|
||||
organization_id text NOT NULL,
|
||||
id uuid NOT NULL,
|
||||
-- This should be indexed. It is intentionally nullable.
|
||||
project_id uuid REFERENCES projects (id) ON DELETE CASCADE,
|
||||
organization_id uuid NOT NULL REFERENCES organizations (id) ON DELETE CASCADE,
|
||||
created_at timestamptz NOT NULL,
|
||||
updated_at timestamptz NOT NULL,
|
||||
-- Name is generated for ease of differentiation.
|
||||
@@ -49,6 +52,7 @@ CREATE TABLE project_versions (
|
||||
description varchar(1048576) NOT NULL,
|
||||
-- The job ID for building the project version.
|
||||
job_id uuid NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
-- Disallow projects to have the same build name
|
||||
-- multiple times.
|
||||
UNIQUE(project_id, name)
|
||||
|
||||
Reference in New Issue
Block a user