Files
coder/database/migrations/000002_projects.up.sql
T
Kyle Carberry bf0ae8f573 feat: Refactor API routes to use UUIDs instead of friendly names (#401)
* Add client for agent

* Cleanup code

* Fix linting error

* Rename routes to be simpler

* Rename workspace history to workspace build

* Refactor HTTP middlewares to use UUIDs

* Cleanup routes

* Compiles!

* Fix files and organizations

* Fix querying

* Fix agent lock

* Cleanup database abstraction

* Add parameters

* Fix linting errors

* Fix log race

* Lock on close wait

* Fix log cleanup

* Fix e2e tests

* Fix upstream version of opencensus-go

* Update coderdtest.go

* Fix coverpkg

* Fix codecov ignore
2022-03-07 11:40:54 -06:00

52 lines
1.8 KiB
SQL

-- Store arbitrary data like project source code or avatars.
CREATE TABLE file (
hash varchar(64) NOT NULL UNIQUE,
created_at timestamptz NOT NULL,
created_by text NOT NULL,
mimetype varchar(64) NOT NULL,
data bytea NOT NULL
);
CREATE TYPE provisioner_type AS ENUM ('echo', 'terraform');
-- Project defines infrastructure that your software project
-- requires for development.
CREATE TABLE project (
id uuid NOT NULL UNIQUE,
created_at timestamptz NOT NULL,
updated_at timestamptz NOT NULL,
-- Projects must be scoped to an organization.
organization_id text NOT NULL,
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,
-- Disallow projects to have the same name under
-- the same organization.
UNIQUE(organization_id, name)
);
-- Project Versions store historical project data. When a Project Version is imported,
-- an "import" job is queued to parse parameters. A Project Version
-- can only be used if the import job succeeds.
CREATE TABLE project_version (
id uuid NOT NULL UNIQUE,
-- This should be indexed.
project_id uuid REFERENCES project (id),
organization_id text NOT NULL,
created_at timestamptz NOT NULL,
updated_at timestamptz NOT NULL,
-- Name is generated for ease of differentiation.
-- eg. TheCozyRabbit16
name varchar(64) NOT NULL,
-- Extracted from a README.md on import.
-- Maximum of 1MB.
description varchar(1048576) NOT NULL,
-- The job ID for building the project version.
job_id uuid NOT NULL,
-- Disallow projects to have the same build name
-- multiple times.
UNIQUE(project_id, name)
);