mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
chore: Rename Projects to Templates (#880)
Customer feedback indicated projects was a confusing name.
After querying the team internally, it seemed unanimous
that it is indeed a confusing name.
Here's for a lil less confusion @ashmeer7 🥂
This commit is contained in:
@ -22,8 +22,8 @@ func New() database.Store {
|
||||
files: make([]database.File, 0),
|
||||
parameterValue: make([]database.ParameterValue, 0),
|
||||
parameterSchema: make([]database.ParameterSchema, 0),
|
||||
project: make([]database.Project, 0),
|
||||
projectVersion: make([]database.ProjectVersion, 0),
|
||||
template: make([]database.Template, 0),
|
||||
templateVersion: make([]database.TemplateVersion, 0),
|
||||
provisionerDaemons: make([]database.ProvisionerDaemon, 0),
|
||||
provisionerJobs: make([]database.ProvisionerJob, 0),
|
||||
provisionerJobLog: make([]database.ProvisionerJobLog, 0),
|
||||
@ -49,8 +49,8 @@ type fakeQuerier struct {
|
||||
files []database.File
|
||||
parameterValue []database.ParameterValue
|
||||
parameterSchema []database.ParameterSchema
|
||||
project []database.Project
|
||||
projectVersion []database.ProjectVersion
|
||||
template []database.Template
|
||||
templateVersion []database.TemplateVersion
|
||||
provisionerDaemons []database.ProvisionerDaemon
|
||||
provisionerJobs []database.ProvisionerJob
|
||||
provisionerJobAgent []database.WorkspaceAgent
|
||||
@ -164,13 +164,13 @@ func (q *fakeQuerier) GetUserCount(_ context.Context) (int64, error) {
|
||||
return int64(len(q.users)), nil
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) GetWorkspacesByProjectID(_ context.Context, arg database.GetWorkspacesByProjectIDParams) ([]database.Workspace, error) {
|
||||
func (q *fakeQuerier) GetWorkspacesByTemplateID(_ context.Context, arg database.GetWorkspacesByTemplateIDParams) ([]database.Workspace, error) {
|
||||
q.mutex.RLock()
|
||||
defer q.mutex.RUnlock()
|
||||
|
||||
workspaces := make([]database.Workspace, 0)
|
||||
for _, workspace := range q.workspace {
|
||||
if workspace.ProjectID.String() != arg.ProjectID.String() {
|
||||
if workspace.TemplateID.String() != arg.TemplateID.String() {
|
||||
continue
|
||||
}
|
||||
if workspace.Deleted != arg.Deleted {
|
||||
@ -215,38 +215,38 @@ func (q *fakeQuerier) GetWorkspaceByUserIDAndName(_ context.Context, arg databas
|
||||
return database.Workspace{}, sql.ErrNoRows
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) GetWorkspaceOwnerCountsByProjectIDs(_ context.Context, projectIDs []uuid.UUID) ([]database.GetWorkspaceOwnerCountsByProjectIDsRow, error) {
|
||||
func (q *fakeQuerier) GetWorkspaceOwnerCountsByTemplateIDs(_ context.Context, templateIDs []uuid.UUID) ([]database.GetWorkspaceOwnerCountsByTemplateIDsRow, error) {
|
||||
q.mutex.RLock()
|
||||
defer q.mutex.RUnlock()
|
||||
|
||||
counts := map[uuid.UUID]map[uuid.UUID]struct{}{}
|
||||
for _, projectID := range projectIDs {
|
||||
for _, templateID := range templateIDs {
|
||||
found := false
|
||||
for _, workspace := range q.workspace {
|
||||
if workspace.ProjectID != projectID {
|
||||
if workspace.TemplateID != templateID {
|
||||
continue
|
||||
}
|
||||
if workspace.Deleted {
|
||||
continue
|
||||
}
|
||||
countByOwnerID, ok := counts[projectID]
|
||||
countByOwnerID, ok := counts[templateID]
|
||||
if !ok {
|
||||
countByOwnerID = map[uuid.UUID]struct{}{}
|
||||
}
|
||||
countByOwnerID[workspace.OwnerID] = struct{}{}
|
||||
counts[projectID] = countByOwnerID
|
||||
counts[templateID] = countByOwnerID
|
||||
found = true
|
||||
break
|
||||
}
|
||||
if !found {
|
||||
counts[projectID] = map[uuid.UUID]struct{}{}
|
||||
counts[templateID] = map[uuid.UUID]struct{}{}
|
||||
}
|
||||
}
|
||||
res := make([]database.GetWorkspaceOwnerCountsByProjectIDsRow, 0)
|
||||
res := make([]database.GetWorkspaceOwnerCountsByTemplateIDsRow, 0)
|
||||
for key, value := range counts {
|
||||
res = append(res, database.GetWorkspaceOwnerCountsByProjectIDsRow{
|
||||
ProjectID: key,
|
||||
Count: int64(len(value)),
|
||||
res = append(res, database.GetWorkspaceOwnerCountsByTemplateIDsRow{
|
||||
TemplateID: key,
|
||||
Count: int64(len(value)),
|
||||
})
|
||||
}
|
||||
if len(res) == 0 {
|
||||
@ -431,47 +431,47 @@ func (q *fakeQuerier) GetParameterValuesByScope(_ context.Context, arg database.
|
||||
return parameterValues, nil
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) GetProjectByID(_ context.Context, id uuid.UUID) (database.Project, error) {
|
||||
func (q *fakeQuerier) GetTemplateByID(_ context.Context, id uuid.UUID) (database.Template, error) {
|
||||
q.mutex.RLock()
|
||||
defer q.mutex.RUnlock()
|
||||
|
||||
for _, project := range q.project {
|
||||
if project.ID.String() == id.String() {
|
||||
return project, nil
|
||||
for _, template := range q.template {
|
||||
if template.ID.String() == id.String() {
|
||||
return template, nil
|
||||
}
|
||||
}
|
||||
return database.Project{}, sql.ErrNoRows
|
||||
return database.Template{}, sql.ErrNoRows
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) GetProjectByOrganizationAndName(_ context.Context, arg database.GetProjectByOrganizationAndNameParams) (database.Project, error) {
|
||||
func (q *fakeQuerier) GetTemplateByOrganizationAndName(_ context.Context, arg database.GetTemplateByOrganizationAndNameParams) (database.Template, error) {
|
||||
q.mutex.RLock()
|
||||
defer q.mutex.RUnlock()
|
||||
|
||||
for _, project := range q.project {
|
||||
if project.OrganizationID != arg.OrganizationID {
|
||||
for _, template := range q.template {
|
||||
if template.OrganizationID != arg.OrganizationID {
|
||||
continue
|
||||
}
|
||||
if !strings.EqualFold(project.Name, arg.Name) {
|
||||
if !strings.EqualFold(template.Name, arg.Name) {
|
||||
continue
|
||||
}
|
||||
if project.Deleted != arg.Deleted {
|
||||
if template.Deleted != arg.Deleted {
|
||||
continue
|
||||
}
|
||||
return project, nil
|
||||
return template, nil
|
||||
}
|
||||
return database.Project{}, sql.ErrNoRows
|
||||
return database.Template{}, sql.ErrNoRows
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) GetProjectVersionsByProjectID(_ context.Context, projectID uuid.UUID) ([]database.ProjectVersion, error) {
|
||||
func (q *fakeQuerier) GetTemplateVersionsByTemplateID(_ context.Context, templateID uuid.UUID) ([]database.TemplateVersion, error) {
|
||||
q.mutex.RLock()
|
||||
defer q.mutex.RUnlock()
|
||||
|
||||
version := make([]database.ProjectVersion, 0)
|
||||
for _, projectVersion := range q.projectVersion {
|
||||
if projectVersion.ProjectID.UUID.String() != projectID.String() {
|
||||
version := make([]database.TemplateVersion, 0)
|
||||
for _, templateVersion := range q.templateVersion {
|
||||
if templateVersion.TemplateID.UUID.String() != templateID.String() {
|
||||
continue
|
||||
}
|
||||
version = append(version, projectVersion)
|
||||
version = append(version, templateVersion)
|
||||
}
|
||||
if len(version) == 0 {
|
||||
return nil, sql.ErrNoRows
|
||||
@ -479,46 +479,46 @@ func (q *fakeQuerier) GetProjectVersionsByProjectID(_ context.Context, projectID
|
||||
return version, nil
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) GetProjectVersionByProjectIDAndName(_ context.Context, arg database.GetProjectVersionByProjectIDAndNameParams) (database.ProjectVersion, error) {
|
||||
func (q *fakeQuerier) GetTemplateVersionByTemplateIDAndName(_ context.Context, arg database.GetTemplateVersionByTemplateIDAndNameParams) (database.TemplateVersion, error) {
|
||||
q.mutex.RLock()
|
||||
defer q.mutex.RUnlock()
|
||||
|
||||
for _, projectVersion := range q.projectVersion {
|
||||
if projectVersion.ProjectID != arg.ProjectID {
|
||||
for _, templateVersion := range q.templateVersion {
|
||||
if templateVersion.TemplateID != arg.TemplateID {
|
||||
continue
|
||||
}
|
||||
if !strings.EqualFold(projectVersion.Name, arg.Name) {
|
||||
if !strings.EqualFold(templateVersion.Name, arg.Name) {
|
||||
continue
|
||||
}
|
||||
return projectVersion, nil
|
||||
return templateVersion, nil
|
||||
}
|
||||
return database.ProjectVersion{}, sql.ErrNoRows
|
||||
return database.TemplateVersion{}, sql.ErrNoRows
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) GetProjectVersionByID(_ context.Context, projectVersionID uuid.UUID) (database.ProjectVersion, error) {
|
||||
func (q *fakeQuerier) GetTemplateVersionByID(_ context.Context, templateVersionID uuid.UUID) (database.TemplateVersion, error) {
|
||||
q.mutex.RLock()
|
||||
defer q.mutex.RUnlock()
|
||||
|
||||
for _, projectVersion := range q.projectVersion {
|
||||
if projectVersion.ID.String() != projectVersionID.String() {
|
||||
for _, templateVersion := range q.templateVersion {
|
||||
if templateVersion.ID.String() != templateVersionID.String() {
|
||||
continue
|
||||
}
|
||||
return projectVersion, nil
|
||||
return templateVersion, nil
|
||||
}
|
||||
return database.ProjectVersion{}, sql.ErrNoRows
|
||||
return database.TemplateVersion{}, sql.ErrNoRows
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) GetProjectVersionByJobID(_ context.Context, jobID uuid.UUID) (database.ProjectVersion, error) {
|
||||
func (q *fakeQuerier) GetTemplateVersionByJobID(_ context.Context, jobID uuid.UUID) (database.TemplateVersion, error) {
|
||||
q.mutex.RLock()
|
||||
defer q.mutex.RUnlock()
|
||||
|
||||
for _, projectVersion := range q.projectVersion {
|
||||
if projectVersion.JobID.String() != jobID.String() {
|
||||
for _, templateVersion := range q.templateVersion {
|
||||
if templateVersion.JobID.String() != jobID.String() {
|
||||
continue
|
||||
}
|
||||
return projectVersion, nil
|
||||
return templateVersion, nil
|
||||
}
|
||||
return database.ProjectVersion{}, sql.ErrNoRows
|
||||
return database.TemplateVersion{}, sql.ErrNoRows
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) GetParameterSchemasByJobID(_ context.Context, jobID uuid.UUID) ([]database.ParameterSchema, error) {
|
||||
@ -557,43 +557,43 @@ func (q *fakeQuerier) GetParameterValueByScopeAndName(_ context.Context, arg dat
|
||||
return database.ParameterValue{}, sql.ErrNoRows
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) GetProjectsByOrganization(_ context.Context, arg database.GetProjectsByOrganizationParams) ([]database.Project, error) {
|
||||
func (q *fakeQuerier) GetTemplatesByOrganization(_ context.Context, arg database.GetTemplatesByOrganizationParams) ([]database.Template, error) {
|
||||
q.mutex.RLock()
|
||||
defer q.mutex.RUnlock()
|
||||
|
||||
projects := make([]database.Project, 0)
|
||||
for _, project := range q.project {
|
||||
if project.Deleted != arg.Deleted {
|
||||
templates := make([]database.Template, 0)
|
||||
for _, template := range q.template {
|
||||
if template.Deleted != arg.Deleted {
|
||||
continue
|
||||
}
|
||||
if project.OrganizationID != arg.OrganizationID {
|
||||
if template.OrganizationID != arg.OrganizationID {
|
||||
continue
|
||||
}
|
||||
projects = append(projects, project)
|
||||
templates = append(templates, template)
|
||||
}
|
||||
if len(projects) == 0 {
|
||||
if len(templates) == 0 {
|
||||
return nil, sql.ErrNoRows
|
||||
}
|
||||
return projects, nil
|
||||
return templates, nil
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) GetProjectsByIDs(_ context.Context, ids []uuid.UUID) ([]database.Project, error) {
|
||||
func (q *fakeQuerier) GetTemplatesByIDs(_ context.Context, ids []uuid.UUID) ([]database.Template, error) {
|
||||
q.mutex.RLock()
|
||||
defer q.mutex.RUnlock()
|
||||
|
||||
projects := make([]database.Project, 0)
|
||||
for _, project := range q.project {
|
||||
templates := make([]database.Template, 0)
|
||||
for _, template := range q.template {
|
||||
for _, id := range ids {
|
||||
if project.ID.String() != id.String() {
|
||||
if template.ID.String() != id.String() {
|
||||
continue
|
||||
}
|
||||
projects = append(projects, project)
|
||||
templates = append(templates, template)
|
||||
}
|
||||
}
|
||||
if len(projects) == 0 {
|
||||
if len(templates) == 0 {
|
||||
return nil, sql.ErrNoRows
|
||||
}
|
||||
return projects, nil
|
||||
return templates, nil
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) GetOrganizationMemberByUserID(_ context.Context, arg database.GetOrganizationMemberByUserIDParams) (database.OrganizationMember, error) {
|
||||
@ -850,12 +850,12 @@ func (q *fakeQuerier) InsertParameterValue(_ context.Context, arg database.Inser
|
||||
return parameterValue, nil
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) InsertProject(_ context.Context, arg database.InsertProjectParams) (database.Project, error) {
|
||||
func (q *fakeQuerier) InsertTemplate(_ context.Context, arg database.InsertTemplateParams) (database.Template, error) {
|
||||
q.mutex.Lock()
|
||||
defer q.mutex.Unlock()
|
||||
|
||||
//nolint:gosimple
|
||||
project := database.Project{
|
||||
template := database.Template{
|
||||
ID: arg.ID,
|
||||
CreatedAt: arg.CreatedAt,
|
||||
UpdatedAt: arg.UpdatedAt,
|
||||
@ -864,18 +864,18 @@ func (q *fakeQuerier) InsertProject(_ context.Context, arg database.InsertProjec
|
||||
Provisioner: arg.Provisioner,
|
||||
ActiveVersionID: arg.ActiveVersionID,
|
||||
}
|
||||
q.project = append(q.project, project)
|
||||
return project, nil
|
||||
q.template = append(q.template, template)
|
||||
return template, nil
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) InsertProjectVersion(_ context.Context, arg database.InsertProjectVersionParams) (database.ProjectVersion, error) {
|
||||
func (q *fakeQuerier) InsertTemplateVersion(_ context.Context, arg database.InsertTemplateVersionParams) (database.TemplateVersion, error) {
|
||||
q.mutex.Lock()
|
||||
defer q.mutex.Unlock()
|
||||
|
||||
//nolint:gosimple
|
||||
version := database.ProjectVersion{
|
||||
version := database.TemplateVersion{
|
||||
ID: arg.ID,
|
||||
ProjectID: arg.ProjectID,
|
||||
TemplateID: arg.TemplateID,
|
||||
OrganizationID: arg.OrganizationID,
|
||||
CreatedAt: arg.CreatedAt,
|
||||
UpdatedAt: arg.UpdatedAt,
|
||||
@ -883,7 +883,7 @@ func (q *fakeQuerier) InsertProjectVersion(_ context.Context, arg database.Inser
|
||||
Description: arg.Description,
|
||||
JobID: arg.JobID,
|
||||
}
|
||||
q.projectVersion = append(q.projectVersion, version)
|
||||
q.templateVersion = append(q.templateVersion, version)
|
||||
return version, nil
|
||||
}
|
||||
|
||||
@ -1033,12 +1033,12 @@ func (q *fakeQuerier) InsertWorkspace(_ context.Context, arg database.InsertWork
|
||||
|
||||
//nolint:gosimple
|
||||
workspace := database.Workspace{
|
||||
ID: arg.ID,
|
||||
CreatedAt: arg.CreatedAt,
|
||||
UpdatedAt: arg.UpdatedAt,
|
||||
OwnerID: arg.OwnerID,
|
||||
ProjectID: arg.ProjectID,
|
||||
Name: arg.Name,
|
||||
ID: arg.ID,
|
||||
CreatedAt: arg.CreatedAt,
|
||||
UpdatedAt: arg.UpdatedAt,
|
||||
OwnerID: arg.OwnerID,
|
||||
TemplateID: arg.TemplateID,
|
||||
Name: arg.Name,
|
||||
}
|
||||
q.workspace = append(q.workspace, workspace)
|
||||
return workspace, nil
|
||||
@ -1049,17 +1049,17 @@ func (q *fakeQuerier) InsertWorkspaceBuild(_ context.Context, arg database.Inser
|
||||
defer q.mutex.Unlock()
|
||||
|
||||
workspaceBuild := database.WorkspaceBuild{
|
||||
ID: arg.ID,
|
||||
CreatedAt: arg.CreatedAt,
|
||||
UpdatedAt: arg.UpdatedAt,
|
||||
WorkspaceID: arg.WorkspaceID,
|
||||
Name: arg.Name,
|
||||
ProjectVersionID: arg.ProjectVersionID,
|
||||
BeforeID: arg.BeforeID,
|
||||
Transition: arg.Transition,
|
||||
InitiatorID: arg.InitiatorID,
|
||||
JobID: arg.JobID,
|
||||
ProvisionerState: arg.ProvisionerState,
|
||||
ID: arg.ID,
|
||||
CreatedAt: arg.CreatedAt,
|
||||
UpdatedAt: arg.UpdatedAt,
|
||||
WorkspaceID: arg.WorkspaceID,
|
||||
Name: arg.Name,
|
||||
TemplateVersionID: arg.TemplateVersionID,
|
||||
BeforeID: arg.BeforeID,
|
||||
Transition: arg.Transition,
|
||||
InitiatorID: arg.InitiatorID,
|
||||
JobID: arg.JobID,
|
||||
ProvisionerState: arg.ProvisionerState,
|
||||
}
|
||||
q.workspaceBuild = append(q.workspaceBuild, workspaceBuild)
|
||||
return workspaceBuild, nil
|
||||
@ -1084,47 +1084,47 @@ func (q *fakeQuerier) UpdateAPIKeyByID(_ context.Context, arg database.UpdateAPI
|
||||
return sql.ErrNoRows
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) UpdateProjectActiveVersionByID(_ context.Context, arg database.UpdateProjectActiveVersionByIDParams) error {
|
||||
func (q *fakeQuerier) UpdateTemplateActiveVersionByID(_ context.Context, arg database.UpdateTemplateActiveVersionByIDParams) error {
|
||||
q.mutex.Lock()
|
||||
defer q.mutex.Unlock()
|
||||
|
||||
for index, project := range q.project {
|
||||
if project.ID.String() != arg.ID.String() {
|
||||
for index, template := range q.template {
|
||||
if template.ID.String() != arg.ID.String() {
|
||||
continue
|
||||
}
|
||||
project.ActiveVersionID = arg.ActiveVersionID
|
||||
q.project[index] = project
|
||||
template.ActiveVersionID = arg.ActiveVersionID
|
||||
q.template[index] = template
|
||||
return nil
|
||||
}
|
||||
return sql.ErrNoRows
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) UpdateProjectDeletedByID(_ context.Context, arg database.UpdateProjectDeletedByIDParams) error {
|
||||
func (q *fakeQuerier) UpdateTemplateDeletedByID(_ context.Context, arg database.UpdateTemplateDeletedByIDParams) error {
|
||||
q.mutex.Lock()
|
||||
defer q.mutex.Unlock()
|
||||
|
||||
for index, project := range q.project {
|
||||
if project.ID.String() != arg.ID.String() {
|
||||
for index, template := range q.template {
|
||||
if template.ID.String() != arg.ID.String() {
|
||||
continue
|
||||
}
|
||||
project.Deleted = arg.Deleted
|
||||
q.project[index] = project
|
||||
template.Deleted = arg.Deleted
|
||||
q.template[index] = template
|
||||
return nil
|
||||
}
|
||||
return sql.ErrNoRows
|
||||
}
|
||||
|
||||
func (q *fakeQuerier) UpdateProjectVersionByID(_ context.Context, arg database.UpdateProjectVersionByIDParams) error {
|
||||
func (q *fakeQuerier) UpdateTemplateVersionByID(_ context.Context, arg database.UpdateTemplateVersionByIDParams) error {
|
||||
q.mutex.Lock()
|
||||
defer q.mutex.Unlock()
|
||||
|
||||
for index, projectVersion := range q.projectVersion {
|
||||
if projectVersion.ID.String() != arg.ID.String() {
|
||||
for index, templateVersion := range q.templateVersion {
|
||||
if templateVersion.ID.String() != arg.ID.String() {
|
||||
continue
|
||||
}
|
||||
projectVersion.ProjectID = arg.ProjectID
|
||||
projectVersion.UpdatedAt = arg.UpdatedAt
|
||||
q.projectVersion[index] = projectVersion
|
||||
templateVersion.TemplateID = arg.TemplateID
|
||||
templateVersion.UpdatedAt = arg.UpdatedAt
|
||||
q.templateVersion[index] = templateVersion
|
||||
return nil
|
||||
}
|
||||
return sql.ErrNoRows
|
||||
|
102
coderd/database/dump.sql
generated
102
coderd/database/dump.sql
generated
@ -27,7 +27,7 @@ CREATE TYPE parameter_destination_scheme AS ENUM (
|
||||
|
||||
CREATE TYPE parameter_scope AS ENUM (
|
||||
'organization',
|
||||
'project',
|
||||
'template',
|
||||
'import_job',
|
||||
'user',
|
||||
'workspace'
|
||||
@ -44,7 +44,7 @@ CREATE TYPE parameter_type_system AS ENUM (
|
||||
);
|
||||
|
||||
CREATE TYPE provisioner_job_type AS ENUM (
|
||||
'project_version_import',
|
||||
'template_version_import',
|
||||
'workspace_build'
|
||||
);
|
||||
|
||||
@ -160,28 +160,6 @@ CREATE TABLE parameter_values (
|
||||
destination_scheme parameter_destination_scheme NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE project_versions (
|
||||
id uuid NOT NULL,
|
||||
project_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,
|
||||
description character varying(1048576) NOT NULL,
|
||||
job_id uuid NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE projects (
|
||||
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,
|
||||
active_version_id uuid NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE provisioner_daemons (
|
||||
id uuid NOT NULL,
|
||||
created_at timestamp with time zone NOT NULL,
|
||||
@ -219,6 +197,28 @@ CREATE TABLE provisioner_jobs (
|
||||
worker_id uuid
|
||||
);
|
||||
|
||||
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,
|
||||
description character varying(1048576) NOT NULL,
|
||||
job_id uuid NOT NULL
|
||||
);
|
||||
|
||||
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,
|
||||
active_version_id uuid NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE users (
|
||||
id uuid NOT NULL,
|
||||
email text NOT NULL,
|
||||
@ -252,7 +252,7 @@ CREATE TABLE workspace_builds (
|
||||
created_at timestamp with time zone NOT NULL,
|
||||
updated_at timestamp with time zone NOT NULL,
|
||||
workspace_id uuid NOT NULL,
|
||||
project_version_id uuid NOT NULL,
|
||||
template_version_id uuid NOT NULL,
|
||||
name character varying(64) NOT NULL,
|
||||
before_id uuid,
|
||||
after_id uuid,
|
||||
@ -278,7 +278,7 @@ CREATE TABLE workspaces (
|
||||
created_at timestamp with time zone NOT NULL,
|
||||
updated_at timestamp with time zone NOT NULL,
|
||||
owner_id uuid NOT NULL,
|
||||
project_id uuid NOT NULL,
|
||||
template_id uuid NOT NULL,
|
||||
deleted boolean DEFAULT false NOT NULL,
|
||||
name character varying(64) NOT NULL
|
||||
);
|
||||
@ -315,18 +315,6 @@ ALTER TABLE ONLY parameter_values
|
||||
ALTER TABLE ONLY parameter_values
|
||||
ADD CONSTRAINT parameter_values_scope_id_name_key UNIQUE (scope_id, name);
|
||||
|
||||
ALTER TABLE ONLY project_versions
|
||||
ADD CONSTRAINT project_versions_pkey PRIMARY KEY (id);
|
||||
|
||||
ALTER TABLE ONLY project_versions
|
||||
ADD CONSTRAINT project_versions_project_id_name_key UNIQUE (project_id, name);
|
||||
|
||||
ALTER TABLE ONLY projects
|
||||
ADD CONSTRAINT projects_organization_id_name_key UNIQUE (organization_id, name);
|
||||
|
||||
ALTER TABLE ONLY projects
|
||||
ADD CONSTRAINT projects_pkey PRIMARY KEY (id);
|
||||
|
||||
ALTER TABLE ONLY provisioner_daemons
|
||||
ADD CONSTRAINT provisioner_daemons_name_key UNIQUE (name);
|
||||
|
||||
@ -339,6 +327,18 @@ ALTER TABLE ONLY provisioner_job_logs
|
||||
ALTER TABLE ONLY provisioner_jobs
|
||||
ADD CONSTRAINT provisioner_jobs_pkey PRIMARY KEY (id);
|
||||
|
||||
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_organization_id_name_key UNIQUE (organization_id, name);
|
||||
|
||||
ALTER TABLE ONLY templates
|
||||
ADD CONSTRAINT templates_pkey PRIMARY KEY (id);
|
||||
|
||||
ALTER TABLE ONLY users
|
||||
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
|
||||
|
||||
@ -373,7 +373,7 @@ CREATE UNIQUE INDEX idx_organization_name ON organizations USING btree (name);
|
||||
|
||||
CREATE UNIQUE INDEX idx_organization_name_lower ON organizations USING btree (lower(name));
|
||||
|
||||
CREATE UNIQUE INDEX idx_projects_name_lower ON projects USING btree (lower((name)::text));
|
||||
CREATE UNIQUE INDEX idx_templates_name_lower ON templates USING btree (lower((name)::text));
|
||||
|
||||
CREATE UNIQUE INDEX idx_users_email ON users USING btree (email);
|
||||
|
||||
@ -381,7 +381,7 @@ CREATE UNIQUE INDEX idx_users_username ON users USING btree (username);
|
||||
|
||||
CREATE UNIQUE INDEX idx_workspaces_name_lower ON workspaces USING btree (lower((name)::text));
|
||||
|
||||
CREATE UNIQUE INDEX projects_organization_id_name_idx ON projects USING btree (organization_id, name) WHERE (deleted = false);
|
||||
CREATE UNIQUE INDEX templates_organization_id_name_idx ON templates USING btree (organization_id, name) WHERE (deleted = false);
|
||||
|
||||
CREATE UNIQUE INDEX users_username_lower_idx ON users USING btree (lower(username));
|
||||
|
||||
@ -402,21 +402,21 @@ ALTER TABLE ONLY organization_members
|
||||
ALTER TABLE ONLY parameter_schemas
|
||||
ADD CONSTRAINT parameter_schemas_job_id_fkey FOREIGN KEY (job_id) REFERENCES provisioner_jobs(id) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE ONLY project_versions
|
||||
ADD CONSTRAINT project_versions_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES organizations(id) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE ONLY project_versions
|
||||
ADD CONSTRAINT project_versions_project_id_fkey FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE ONLY projects
|
||||
ADD CONSTRAINT projects_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES organizations(id) ON DELETE CASCADE;
|
||||
|
||||
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;
|
||||
|
||||
ALTER TABLE ONLY provisioner_jobs
|
||||
ADD CONSTRAINT provisioner_jobs_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES organizations(id) ON DELETE CASCADE;
|
||||
|
||||
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;
|
||||
|
||||
ALTER TABLE ONLY templates
|
||||
ADD CONSTRAINT templates_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES organizations(id) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE ONLY workspace_agents
|
||||
ADD CONSTRAINT workspace_agents_resource_id_fkey FOREIGN KEY (resource_id) REFERENCES workspace_resources(id) ON DELETE CASCADE;
|
||||
|
||||
@ -424,7 +424,7 @@ ALTER TABLE ONLY workspace_builds
|
||||
ADD CONSTRAINT workspace_builds_job_id_fkey FOREIGN KEY (job_id) REFERENCES provisioner_jobs(id) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE ONLY workspace_builds
|
||||
ADD CONSTRAINT workspace_builds_project_version_id_fkey FOREIGN KEY (project_version_id) REFERENCES project_versions(id) ON DELETE CASCADE;
|
||||
ADD CONSTRAINT workspace_builds_template_version_id_fkey FOREIGN KEY (template_version_id) REFERENCES template_versions(id) ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE ONLY workspace_builds
|
||||
ADD CONSTRAINT workspace_builds_workspace_id_fkey FOREIGN KEY (workspace_id) REFERENCES workspaces(id) ON DELETE CASCADE;
|
||||
@ -436,5 +436,5 @@ ALTER TABLE ONLY workspaces
|
||||
ADD CONSTRAINT workspaces_owner_id_fkey FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT;
|
||||
|
||||
ALTER TABLE ONLY workspaces
|
||||
ADD CONSTRAINT workspaces_project_id_fkey FOREIGN KEY (project_id) REFERENCES projects(id) ON DELETE RESTRICT;
|
||||
ADD CONSTRAINT workspaces_template_id_fkey FOREIGN KEY (template_id) REFERENCES templates(id) ON DELETE RESTRICT;
|
||||
|
||||
|
@ -1,6 +0,0 @@
|
||||
DROP TABLE project_versions;
|
||||
|
||||
DROP TABLE projects;
|
||||
DROP TYPE provisioner_type;
|
||||
|
||||
DROP TABLE files;
|
6
coderd/database/migrations/000002_templates.down.sql
Normal file
6
coderd/database/migrations/000002_templates.down.sql
Normal file
@ -0,0 +1,6 @@
|
||||
DROP TABLE template_versions;
|
||||
|
||||
DROP TABLE templates;
|
||||
DROP TYPE provisioner_type;
|
||||
|
||||
DROP TABLE files;
|
@ -1,4 +1,4 @@
|
||||
-- Store arbitrary data like project source code or avatars.
|
||||
-- Store arbitrary data like template source code or avatars.
|
||||
CREATE TABLE files (
|
||||
hash varchar(64) NOT NULL,
|
||||
created_at timestamptz NOT NULL,
|
||||
@ -11,37 +11,37 @@ CREATE TABLE files (
|
||||
|
||||
CREATE TYPE provisioner_type AS ENUM ('echo', 'terraform');
|
||||
|
||||
-- Project defines infrastructure that your software project
|
||||
-- Template defines infrastructure that your software template
|
||||
-- requires for development.
|
||||
CREATE TABLE projects (
|
||||
CREATE TABLE templates (
|
||||
id uuid NOT NULL,
|
||||
created_at timestamptz NOT NULL,
|
||||
updated_at timestamptz NOT NULL,
|
||||
-- Projects must be scoped to an organization.
|
||||
-- Templates must be scoped to an organization.
|
||||
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.
|
||||
-- Target's a Template 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
|
||||
-- Disallow templates to have the same name under
|
||||
-- the same organization.
|
||||
UNIQUE(organization_id, name)
|
||||
);
|
||||
|
||||
-- Enforces no active projects have the same name.
|
||||
CREATE UNIQUE INDEX ON projects (organization_id, name) WHERE deleted = FALSE;
|
||||
CREATE UNIQUE INDEX idx_projects_name_lower ON projects USING btree (lower(name));
|
||||
-- Enforces no active templates have the same name.
|
||||
CREATE UNIQUE INDEX ON templates (organization_id, name) WHERE deleted = FALSE;
|
||||
CREATE UNIQUE INDEX idx_templates_name_lower ON templates USING btree (lower(name));
|
||||
|
||||
-- Project Versions store historical project data. When a Project Version is imported,
|
||||
-- an "import" job is queued to parse parameters. A Project Version
|
||||
-- Template Versions store historical template data. When a Template Version is imported,
|
||||
-- an "import" job is queued to parse parameters. A Template Version
|
||||
-- can only be used if the import job succeeds.
|
||||
CREATE TABLE project_versions (
|
||||
CREATE TABLE template_versions (
|
||||
id uuid NOT NULL,
|
||||
-- This should be indexed. It is intentionally nullable.
|
||||
project_id uuid REFERENCES projects (id) ON DELETE CASCADE,
|
||||
template_id uuid REFERENCES templates (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,
|
||||
@ -51,10 +51,10 @@ CREATE TABLE project_versions (
|
||||
-- Extracted from a README.md on import.
|
||||
-- Maximum of 1MB.
|
||||
description varchar(1048576) NOT NULL,
|
||||
-- The job ID for building the project version.
|
||||
-- The job ID for building the template version.
|
||||
job_id uuid NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
-- Disallow projects to have the same build name
|
||||
-- Disallow templates to have the same build name
|
||||
-- multiple times.
|
||||
UNIQUE(project_id, name)
|
||||
UNIQUE(template_id, name)
|
||||
);
|
@ -5,7 +5,7 @@ CREATE TABLE workspaces (
|
||||
-- Use ON DELETE RESTRICT so that we can cleanup external workspace
|
||||
-- resources first.
|
||||
owner_id uuid NOT NULL REFERENCES users (id) ON DELETE RESTRICT,
|
||||
project_id uuid NOT NULL REFERENCES projects (id) ON DELETE RESTRICT,
|
||||
template_id uuid NOT NULL REFERENCES templates (id) ON DELETE RESTRICT,
|
||||
deleted boolean NOT NULL DEFAULT FALSE,
|
||||
name varchar(64) NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
|
@ -11,7 +11,7 @@ CREATE TABLE IF NOT EXISTS provisioner_daemons (
|
||||
);
|
||||
|
||||
CREATE TYPE provisioner_job_type AS ENUM (
|
||||
'project_version_import',
|
||||
'template_version_import',
|
||||
'workspace_build'
|
||||
);
|
||||
|
||||
@ -92,7 +92,7 @@ CREATE TABLE workspace_agents (
|
||||
|
||||
CREATE TYPE parameter_scope AS ENUM (
|
||||
'organization',
|
||||
'project',
|
||||
'template',
|
||||
'import_job',
|
||||
'user',
|
||||
'workspace'
|
||||
@ -107,7 +107,7 @@ CREATE TYPE parameter_source_scheme AS ENUM('none', 'data');
|
||||
-- Supported schemes for a parameter destination.
|
||||
CREATE TYPE parameter_destination_scheme AS ENUM('none', 'environment_variable', 'provisioner_variable');
|
||||
|
||||
-- Stores project version parameters parsed on import.
|
||||
-- Stores template version parameters parsed on import.
|
||||
-- No secrets are stored here.
|
||||
--
|
||||
-- All parameter validation occurs server-side to process
|
||||
@ -162,7 +162,7 @@ CREATE TABLE workspace_builds (
|
||||
created_at timestamptz NOT NULL,
|
||||
updated_at timestamptz NOT NULL,
|
||||
workspace_id uuid NOT NULL REFERENCES workspaces (id) ON DELETE CASCADE,
|
||||
project_version_id uuid NOT NULL REFERENCES project_versions (id) ON DELETE CASCADE,
|
||||
template_version_id uuid NOT NULL REFERENCES template_versions (id) ON DELETE CASCADE,
|
||||
name varchar(64) NOT NULL,
|
||||
before_id uuid,
|
||||
after_id uuid,
|
||||
|
@ -97,7 +97,7 @@ type ParameterScope string
|
||||
|
||||
const (
|
||||
ParameterScopeOrganization ParameterScope = "organization"
|
||||
ParameterScopeProject ParameterScope = "project"
|
||||
ParameterScopeTemplate ParameterScope = "template"
|
||||
ParameterScopeImportJob ParameterScope = "import_job"
|
||||
ParameterScopeUser ParameterScope = "user"
|
||||
ParameterScopeWorkspace ParameterScope = "workspace"
|
||||
@ -156,8 +156,8 @@ func (e *ParameterTypeSystem) Scan(src interface{}) error {
|
||||
type ProvisionerJobType string
|
||||
|
||||
const (
|
||||
ProvisionerJobTypeProjectVersionImport ProvisionerJobType = "project_version_import"
|
||||
ProvisionerJobTypeWorkspaceBuild ProvisionerJobType = "workspace_build"
|
||||
ProvisionerJobTypeTemplateVersionImport ProvisionerJobType = "template_version_import"
|
||||
ProvisionerJobTypeWorkspaceBuild ProvisionerJobType = "workspace_build"
|
||||
)
|
||||
|
||||
func (e *ProvisionerJobType) Scan(src interface{}) error {
|
||||
@ -316,28 +316,6 @@ type ParameterValue struct {
|
||||
DestinationScheme ParameterDestinationScheme `db:"destination_scheme" json:"destination_scheme"`
|
||||
}
|
||||
|
||||
type Project struct {
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||
OrganizationID uuid.UUID `db:"organization_id" json:"organization_id"`
|
||||
Deleted bool `db:"deleted" json:"deleted"`
|
||||
Name string `db:"name" json:"name"`
|
||||
Provisioner ProvisionerType `db:"provisioner" json:"provisioner"`
|
||||
ActiveVersionID uuid.UUID `db:"active_version_id" json:"active_version_id"`
|
||||
}
|
||||
|
||||
type ProjectVersion struct {
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
ProjectID uuid.NullUUID `db:"project_id" json:"project_id"`
|
||||
OrganizationID uuid.UUID `db:"organization_id" json:"organization_id"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||
Name string `db:"name" json:"name"`
|
||||
Description string `db:"description" json:"description"`
|
||||
JobID uuid.UUID `db:"job_id" json:"job_id"`
|
||||
}
|
||||
|
||||
type ProvisionerDaemon struct {
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
@ -375,6 +353,28 @@ type ProvisionerJobLog struct {
|
||||
Output string `db:"output" json:"output"`
|
||||
}
|
||||
|
||||
type Template struct {
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||
OrganizationID uuid.UUID `db:"organization_id" json:"organization_id"`
|
||||
Deleted bool `db:"deleted" json:"deleted"`
|
||||
Name string `db:"name" json:"name"`
|
||||
Provisioner ProvisionerType `db:"provisioner" json:"provisioner"`
|
||||
ActiveVersionID uuid.UUID `db:"active_version_id" json:"active_version_id"`
|
||||
}
|
||||
|
||||
type TemplateVersion struct {
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
TemplateID uuid.NullUUID `db:"template_id" json:"template_id"`
|
||||
OrganizationID uuid.UUID `db:"organization_id" json:"organization_id"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||
Name string `db:"name" json:"name"`
|
||||
Description string `db:"description" json:"description"`
|
||||
JobID uuid.UUID `db:"job_id" json:"job_id"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
Email string `db:"email" json:"email"`
|
||||
@ -388,13 +388,13 @@ type User struct {
|
||||
}
|
||||
|
||||
type Workspace struct {
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||
OwnerID uuid.UUID `db:"owner_id" json:"owner_id"`
|
||||
ProjectID uuid.UUID `db:"project_id" json:"project_id"`
|
||||
Deleted bool `db:"deleted" json:"deleted"`
|
||||
Name string `db:"name" json:"name"`
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||
OwnerID uuid.UUID `db:"owner_id" json:"owner_id"`
|
||||
TemplateID uuid.UUID `db:"template_id" json:"template_id"`
|
||||
Deleted bool `db:"deleted" json:"deleted"`
|
||||
Name string `db:"name" json:"name"`
|
||||
}
|
||||
|
||||
type WorkspaceAgent struct {
|
||||
@ -414,18 +414,18 @@ type WorkspaceAgent struct {
|
||||
}
|
||||
|
||||
type WorkspaceBuild struct {
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||
WorkspaceID uuid.UUID `db:"workspace_id" json:"workspace_id"`
|
||||
ProjectVersionID uuid.UUID `db:"project_version_id" json:"project_version_id"`
|
||||
Name string `db:"name" json:"name"`
|
||||
BeforeID uuid.NullUUID `db:"before_id" json:"before_id"`
|
||||
AfterID uuid.NullUUID `db:"after_id" json:"after_id"`
|
||||
Transition WorkspaceTransition `db:"transition" json:"transition"`
|
||||
InitiatorID uuid.UUID `db:"initiator_id" json:"initiator_id"`
|
||||
ProvisionerState []byte `db:"provisioner_state" json:"provisioner_state"`
|
||||
JobID uuid.UUID `db:"job_id" json:"job_id"`
|
||||
ID uuid.UUID `db:"id" json:"id"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||
WorkspaceID uuid.UUID `db:"workspace_id" json:"workspace_id"`
|
||||
TemplateVersionID uuid.UUID `db:"template_version_id" json:"template_version_id"`
|
||||
Name string `db:"name" json:"name"`
|
||||
BeforeID uuid.NullUUID `db:"before_id" json:"before_id"`
|
||||
AfterID uuid.NullUUID `db:"after_id" json:"after_id"`
|
||||
Transition WorkspaceTransition `db:"transition" json:"transition"`
|
||||
InitiatorID uuid.UUID `db:"initiator_id" json:"initiator_id"`
|
||||
ProvisionerState []byte `db:"provisioner_state" json:"provisioner_state"`
|
||||
JobID uuid.UUID `db:"job_id" json:"job_id"`
|
||||
}
|
||||
|
||||
type WorkspaceResource struct {
|
||||
|
@ -22,19 +22,19 @@ type querier interface {
|
||||
GetParameterSchemasByJobID(ctx context.Context, jobID uuid.UUID) ([]ParameterSchema, error)
|
||||
GetParameterValueByScopeAndName(ctx context.Context, arg GetParameterValueByScopeAndNameParams) (ParameterValue, error)
|
||||
GetParameterValuesByScope(ctx context.Context, arg GetParameterValuesByScopeParams) ([]ParameterValue, error)
|
||||
GetProjectByID(ctx context.Context, id uuid.UUID) (Project, error)
|
||||
GetProjectByOrganizationAndName(ctx context.Context, arg GetProjectByOrganizationAndNameParams) (Project, error)
|
||||
GetProjectVersionByID(ctx context.Context, id uuid.UUID) (ProjectVersion, error)
|
||||
GetProjectVersionByJobID(ctx context.Context, jobID uuid.UUID) (ProjectVersion, error)
|
||||
GetProjectVersionByProjectIDAndName(ctx context.Context, arg GetProjectVersionByProjectIDAndNameParams) (ProjectVersion, error)
|
||||
GetProjectVersionsByProjectID(ctx context.Context, dollar_1 uuid.UUID) ([]ProjectVersion, error)
|
||||
GetProjectsByIDs(ctx context.Context, ids []uuid.UUID) ([]Project, error)
|
||||
GetProjectsByOrganization(ctx context.Context, arg GetProjectsByOrganizationParams) ([]Project, error)
|
||||
GetProvisionerDaemonByID(ctx context.Context, id uuid.UUID) (ProvisionerDaemon, error)
|
||||
GetProvisionerDaemons(ctx context.Context) ([]ProvisionerDaemon, error)
|
||||
GetProvisionerJobByID(ctx context.Context, id uuid.UUID) (ProvisionerJob, error)
|
||||
GetProvisionerJobsByIDs(ctx context.Context, ids []uuid.UUID) ([]ProvisionerJob, error)
|
||||
GetProvisionerLogsByIDBetween(ctx context.Context, arg GetProvisionerLogsByIDBetweenParams) ([]ProvisionerJobLog, error)
|
||||
GetTemplateByID(ctx context.Context, id uuid.UUID) (Template, error)
|
||||
GetTemplateByOrganizationAndName(ctx context.Context, arg GetTemplateByOrganizationAndNameParams) (Template, error)
|
||||
GetTemplateVersionByID(ctx context.Context, id uuid.UUID) (TemplateVersion, error)
|
||||
GetTemplateVersionByJobID(ctx context.Context, jobID uuid.UUID) (TemplateVersion, error)
|
||||
GetTemplateVersionByTemplateIDAndName(ctx context.Context, arg GetTemplateVersionByTemplateIDAndNameParams) (TemplateVersion, error)
|
||||
GetTemplateVersionsByTemplateID(ctx context.Context, dollar_1 uuid.UUID) ([]TemplateVersion, error)
|
||||
GetTemplatesByIDs(ctx context.Context, ids []uuid.UUID) ([]Template, error)
|
||||
GetTemplatesByOrganization(ctx context.Context, arg GetTemplatesByOrganizationParams) ([]Template, error)
|
||||
GetUserByEmailOrUsername(ctx context.Context, arg GetUserByEmailOrUsernameParams) (User, error)
|
||||
GetUserByID(ctx context.Context, id uuid.UUID) (User, error)
|
||||
GetUserCount(ctx context.Context) (int64, error)
|
||||
@ -49,10 +49,10 @@ type querier interface {
|
||||
GetWorkspaceBuildsByWorkspaceIDsWithoutAfter(ctx context.Context, ids []uuid.UUID) ([]WorkspaceBuild, error)
|
||||
GetWorkspaceByID(ctx context.Context, id uuid.UUID) (Workspace, error)
|
||||
GetWorkspaceByUserIDAndName(ctx context.Context, arg GetWorkspaceByUserIDAndNameParams) (Workspace, error)
|
||||
GetWorkspaceOwnerCountsByProjectIDs(ctx context.Context, ids []uuid.UUID) ([]GetWorkspaceOwnerCountsByProjectIDsRow, error)
|
||||
GetWorkspaceOwnerCountsByTemplateIDs(ctx context.Context, ids []uuid.UUID) ([]GetWorkspaceOwnerCountsByTemplateIDsRow, error)
|
||||
GetWorkspaceResourceByID(ctx context.Context, id uuid.UUID) (WorkspaceResource, error)
|
||||
GetWorkspaceResourcesByJobID(ctx context.Context, jobID uuid.UUID) ([]WorkspaceResource, error)
|
||||
GetWorkspacesByProjectID(ctx context.Context, arg GetWorkspacesByProjectIDParams) ([]Workspace, error)
|
||||
GetWorkspacesByTemplateID(ctx context.Context, arg GetWorkspacesByTemplateIDParams) ([]Workspace, error)
|
||||
GetWorkspacesByUserID(ctx context.Context, arg GetWorkspacesByUserIDParams) ([]Workspace, error)
|
||||
InsertAPIKey(ctx context.Context, arg InsertAPIKeyParams) (APIKey, error)
|
||||
InsertFile(ctx context.Context, arg InsertFileParams) (File, error)
|
||||
@ -61,11 +61,11 @@ type querier interface {
|
||||
InsertOrganizationMember(ctx context.Context, arg InsertOrganizationMemberParams) (OrganizationMember, error)
|
||||
InsertParameterSchema(ctx context.Context, arg InsertParameterSchemaParams) (ParameterSchema, error)
|
||||
InsertParameterValue(ctx context.Context, arg InsertParameterValueParams) (ParameterValue, error)
|
||||
InsertProject(ctx context.Context, arg InsertProjectParams) (Project, error)
|
||||
InsertProjectVersion(ctx context.Context, arg InsertProjectVersionParams) (ProjectVersion, error)
|
||||
InsertProvisionerDaemon(ctx context.Context, arg InsertProvisionerDaemonParams) (ProvisionerDaemon, error)
|
||||
InsertProvisionerJob(ctx context.Context, arg InsertProvisionerJobParams) (ProvisionerJob, error)
|
||||
InsertProvisionerJobLogs(ctx context.Context, arg InsertProvisionerJobLogsParams) ([]ProvisionerJobLog, error)
|
||||
InsertTemplate(ctx context.Context, arg InsertTemplateParams) (Template, error)
|
||||
InsertTemplateVersion(ctx context.Context, arg InsertTemplateVersionParams) (TemplateVersion, error)
|
||||
InsertUser(ctx context.Context, arg InsertUserParams) (User, error)
|
||||
InsertWorkspace(ctx context.Context, arg InsertWorkspaceParams) (Workspace, error)
|
||||
InsertWorkspaceAgent(ctx context.Context, arg InsertWorkspaceAgentParams) (WorkspaceAgent, error)
|
||||
@ -73,13 +73,13 @@ type querier interface {
|
||||
InsertWorkspaceResource(ctx context.Context, arg InsertWorkspaceResourceParams) (WorkspaceResource, error)
|
||||
UpdateAPIKeyByID(ctx context.Context, arg UpdateAPIKeyByIDParams) error
|
||||
UpdateGitSSHKey(ctx context.Context, arg UpdateGitSSHKeyParams) error
|
||||
UpdateProjectActiveVersionByID(ctx context.Context, arg UpdateProjectActiveVersionByIDParams) error
|
||||
UpdateProjectDeletedByID(ctx context.Context, arg UpdateProjectDeletedByIDParams) error
|
||||
UpdateProjectVersionByID(ctx context.Context, arg UpdateProjectVersionByIDParams) error
|
||||
UpdateProvisionerDaemonByID(ctx context.Context, arg UpdateProvisionerDaemonByIDParams) error
|
||||
UpdateProvisionerJobByID(ctx context.Context, arg UpdateProvisionerJobByIDParams) error
|
||||
UpdateProvisionerJobWithCancelByID(ctx context.Context, arg UpdateProvisionerJobWithCancelByIDParams) error
|
||||
UpdateProvisionerJobWithCompleteByID(ctx context.Context, arg UpdateProvisionerJobWithCompleteByIDParams) error
|
||||
UpdateTemplateActiveVersionByID(ctx context.Context, arg UpdateTemplateActiveVersionByIDParams) error
|
||||
UpdateTemplateDeletedByID(ctx context.Context, arg UpdateTemplateDeletedByIDParams) error
|
||||
UpdateTemplateVersionByID(ctx context.Context, arg UpdateTemplateVersionByIDParams) error
|
||||
UpdateWorkspaceAgentConnectionByID(ctx context.Context, arg UpdateWorkspaceAgentConnectionByIDParams) error
|
||||
UpdateWorkspaceBuildByID(ctx context.Context, arg UpdateWorkspaceBuildByIDParams) error
|
||||
UpdateWorkspaceDeletedByID(ctx context.Context, arg UpdateWorkspaceDeletedByIDParams) error
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,56 +0,0 @@
|
||||
-- name: GetProjectVersionsByProjectID :many
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
project_versions
|
||||
WHERE
|
||||
project_id = $1 :: uuid;
|
||||
|
||||
-- name: GetProjectVersionByJobID :one
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
project_versions
|
||||
WHERE
|
||||
job_id = $1;
|
||||
|
||||
-- name: GetProjectVersionByProjectIDAndName :one
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
project_versions
|
||||
WHERE
|
||||
project_id = $1
|
||||
AND "name" = $2;
|
||||
|
||||
-- name: GetProjectVersionByID :one
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
project_versions
|
||||
WHERE
|
||||
id = $1;
|
||||
|
||||
-- name: InsertProjectVersion :one
|
||||
INSERT INTO
|
||||
project_versions (
|
||||
id,
|
||||
project_id,
|
||||
organization_id,
|
||||
created_at,
|
||||
updated_at,
|
||||
"name",
|
||||
description,
|
||||
job_id
|
||||
)
|
||||
VALUES
|
||||
($1, $2, $3, $4, $5, $6, $7, $8) RETURNING *;
|
||||
|
||||
-- name: UpdateProjectVersionByID :exec
|
||||
UPDATE
|
||||
project_versions
|
||||
SET
|
||||
project_id = $2,
|
||||
updated_at = $3
|
||||
WHERE
|
||||
id = $1;
|
@ -1,26 +1,26 @@
|
||||
-- name: GetProjectByID :one
|
||||
-- name: GetTemplateByID :one
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
projects
|
||||
templates
|
||||
WHERE
|
||||
id = $1
|
||||
LIMIT
|
||||
1;
|
||||
|
||||
-- name: GetProjectsByIDs :many
|
||||
-- name: GetTemplatesByIDs :many
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
projects
|
||||
templates
|
||||
WHERE
|
||||
id = ANY(@ids :: uuid [ ]);
|
||||
|
||||
-- name: GetProjectByOrganizationAndName :one
|
||||
-- name: GetTemplateByOrganizationAndName :one
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
projects
|
||||
templates
|
||||
WHERE
|
||||
organization_id = @organization_id
|
||||
AND deleted = @deleted
|
||||
@ -28,18 +28,18 @@ WHERE
|
||||
LIMIT
|
||||
1;
|
||||
|
||||
-- name: GetProjectsByOrganization :many
|
||||
-- name: GetTemplatesByOrganization :many
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
projects
|
||||
templates
|
||||
WHERE
|
||||
organization_id = $1
|
||||
AND deleted = $2;
|
||||
|
||||
-- name: InsertProject :one
|
||||
-- name: InsertTemplate :one
|
||||
INSERT INTO
|
||||
projects (
|
||||
templates (
|
||||
id,
|
||||
created_at,
|
||||
updated_at,
|
||||
@ -51,17 +51,17 @@ INSERT INTO
|
||||
VALUES
|
||||
($1, $2, $3, $4, $5, $6, $7) RETURNING *;
|
||||
|
||||
-- name: UpdateProjectActiveVersionByID :exec
|
||||
-- name: UpdateTemplateActiveVersionByID :exec
|
||||
UPDATE
|
||||
projects
|
||||
templates
|
||||
SET
|
||||
active_version_id = $2
|
||||
WHERE
|
||||
id = $1;
|
||||
|
||||
-- name: UpdateProjectDeletedByID :exec
|
||||
-- name: UpdateTemplateDeletedByID :exec
|
||||
UPDATE
|
||||
projects
|
||||
templates
|
||||
SET
|
||||
deleted = $2
|
||||
WHERE
|
56
coderd/database/queries/templateversions.sql
Normal file
56
coderd/database/queries/templateversions.sql
Normal file
@ -0,0 +1,56 @@
|
||||
-- name: GetTemplateVersionsByTemplateID :many
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
template_versions
|
||||
WHERE
|
||||
template_id = $1 :: uuid;
|
||||
|
||||
-- name: GetTemplateVersionByJobID :one
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
template_versions
|
||||
WHERE
|
||||
job_id = $1;
|
||||
|
||||
-- name: GetTemplateVersionByTemplateIDAndName :one
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
template_versions
|
||||
WHERE
|
||||
template_id = $1
|
||||
AND "name" = $2;
|
||||
|
||||
-- name: GetTemplateVersionByID :one
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
template_versions
|
||||
WHERE
|
||||
id = $1;
|
||||
|
||||
-- name: InsertTemplateVersion :one
|
||||
INSERT INTO
|
||||
template_versions (
|
||||
id,
|
||||
template_id,
|
||||
organization_id,
|
||||
created_at,
|
||||
updated_at,
|
||||
"name",
|
||||
description,
|
||||
job_id
|
||||
)
|
||||
VALUES
|
||||
($1, $2, $3, $4, $5, $6, $7, $8) RETURNING *;
|
||||
|
||||
-- name: UpdateTemplateVersionByID :exec
|
||||
UPDATE
|
||||
template_versions
|
||||
SET
|
||||
template_id = $2,
|
||||
updated_at = $3
|
||||
WHERE
|
||||
id = $1;
|
@ -62,7 +62,7 @@ INSERT INTO
|
||||
created_at,
|
||||
updated_at,
|
||||
workspace_id,
|
||||
project_version_id,
|
||||
template_version_id,
|
||||
before_id,
|
||||
"name",
|
||||
transition,
|
||||
|
@ -8,13 +8,13 @@ WHERE
|
||||
LIMIT
|
||||
1;
|
||||
|
||||
-- name: GetWorkspacesByProjectID :many
|
||||
-- name: GetWorkspacesByTemplateID :many
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
workspaces
|
||||
WHERE
|
||||
project_id = $1
|
||||
template_id = $1
|
||||
AND deleted = $2;
|
||||
|
||||
-- name: GetWorkspacesByUserID :many
|
||||
@ -36,16 +36,16 @@ WHERE
|
||||
AND deleted = @deleted
|
||||
AND LOWER("name") = LOWER(@name);
|
||||
|
||||
-- name: GetWorkspaceOwnerCountsByProjectIDs :many
|
||||
-- name: GetWorkspaceOwnerCountsByTemplateIDs :many
|
||||
SELECT
|
||||
project_id,
|
||||
template_id,
|
||||
COUNT(DISTINCT owner_id)
|
||||
FROM
|
||||
workspaces
|
||||
WHERE
|
||||
project_id = ANY(@ids :: uuid [ ])
|
||||
template_id = ANY(@ids :: uuid [ ])
|
||||
GROUP BY
|
||||
project_id,
|
||||
template_id,
|
||||
owner_id;
|
||||
|
||||
-- name: InsertWorkspace :one
|
||||
@ -55,7 +55,7 @@ INSERT INTO
|
||||
created_at,
|
||||
updated_at,
|
||||
owner_id,
|
||||
project_id,
|
||||
template_id,
|
||||
name
|
||||
)
|
||||
VALUES
|
||||
|
Reference in New Issue
Block a user