|
| 1 | +CREATE TYPE provisioner_type AS ENUM ('terraform', 'cdr-basic'); |
| 2 | + |
| 3 | +-- Project defines infrastructure that your software project |
| 4 | +-- requires for development. |
| 5 | +CREATE TABLE project ( |
| 6 | + id uuid NOT NULL UNIQUE, |
| 7 | + created timestamptz NOT NULL, |
| 8 | + updated timestamptz NOT NULL, |
| 9 | + -- Projects must be scoped to an organization. |
| 10 | + organization_id text NOT NULL, |
| 11 | + name varchar(64) NOT NULL, |
| 12 | + provisioner provisioner_type NOT NULL, |
| 13 | + -- Target's a Project Version to use for Workspaces. |
| 14 | + -- If a Workspace doesn't match this version, it will be prompted to rebuild. |
| 15 | + active_version_id uuid, |
| 16 | + -- Disallow projects to have the same name under |
| 17 | + -- the same organization. |
| 18 | + UNIQUE(organization_id, name) |
| 19 | +); |
| 20 | + |
| 21 | +CREATE TYPE project_storage_method AS ENUM ('inline-archive'); |
| 22 | + |
| 23 | +-- Project Versions store Project history. When a Project Version is imported, |
| 24 | +-- an "import" job is queued to parse parameters. A Project Version |
| 25 | +-- can only be used if the import job succeeds. |
| 26 | +CREATE TABLE project_history ( |
| 27 | + id uuid NOT NULL UNIQUE, |
| 28 | + -- This should be indexed. |
| 29 | + project_id uuid NOT NULL REFERENCES project (id), |
| 30 | + created timestamptz NOT NULL, |
| 31 | + updated timestamptz NOT NULL, |
| 32 | + -- Name is generated for ease of differentiation. |
| 33 | + -- eg. TheCozyRabbit16 |
| 34 | + name varchar(64) NOT NULL, |
| 35 | + -- Extracted from a README.md on import. |
| 36 | + -- Maximum of 1MB. |
| 37 | + description varchar(1048576) NOT NULL, |
| 38 | + storage_method project_storage_method NOT NULL, |
| 39 | + storage_source bytea NOT NULL, |
| 40 | + -- The import job for a Project Version. This is used |
| 41 | + -- to detect if an import was successful. |
| 42 | + import_job_id uuid NOT NULL, |
| 43 | + -- Disallow projects to have the same build name |
| 44 | + -- multiple times. |
| 45 | + UNIQUE(project_id, name) |
| 46 | +); |
| 47 | + |
| 48 | +-- Types of parameters the automator supports. |
| 49 | +CREATE TYPE parameter_type_system AS ENUM ('hcl'); |
| 50 | + |
| 51 | +-- Stores project version parameters parsed on import. |
| 52 | +-- No secrets are stored here. |
| 53 | +-- |
| 54 | +-- All parameter validation occurs server-side to process |
| 55 | +-- complex validations. |
| 56 | +-- |
| 57 | +-- Parameter types, description, and validation will produce |
| 58 | +-- a UI for users to enter values. |
| 59 | +-- Needs to be made consistent with the examples below. |
| 60 | +CREATE TABLE project_parameter ( |
| 61 | + id uuid NOT NULL UNIQUE, |
| 62 | + project_history_id uuid NOT NULL REFERENCES project_history(id) ON DELETE CASCADE, |
| 63 | + name varchar(64) NOT NULL, |
| 64 | + -- 8KB limit |
| 65 | + description varchar(8192) NOT NULL DEFAULT '', |
| 66 | + -- eg. data://inlinevalue |
| 67 | + default_source text, |
| 68 | + -- Allows the user to override the source. |
| 69 | + allow_override_source boolean NOT null, |
| 70 | + -- eg. env://SOME_VARIABLE, tfvars://example |
| 71 | + default_destination text, |
| 72 | + -- Allows the user to override the destination. |
| 73 | + allow_override_destination boolean NOT null, |
| 74 | + default_refresh text NOT NULL, |
| 75 | + -- Whether the consumer can view the source and destinations. |
| 76 | + redisplay_value boolean NOT null, |
| 77 | + -- This error would appear in the UI if the condition is not met. |
| 78 | + validation_error varchar(256) NOT NULL, |
| 79 | + validation_condition varchar(512) NOT NULL, |
| 80 | + validation_type_system parameter_type_system NOT NULL, |
| 81 | + validation_value_type varchar(64) NOT NULL, |
| 82 | + UNIQUE(project_history_id, name) |
| 83 | +); |
0 commit comments