Skip to content

chore: support the has_ai_task column in template version and workspace insert queries #18385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions coderd/database/dbgen/dbgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ func WorkspaceBuild(t testing.TB, db database.Store, orig database.WorkspaceBuil
UUID: uuid.UUID{},
Valid: false,
}),
HasAITask: orig.HasAITask,
})
if err != nil {
return err
Expand Down Expand Up @@ -943,6 +944,7 @@ func TemplateVersion(t testing.TB, db database.Store, orig database.TemplateVers
JobID: takeFirst(orig.JobID, uuid.New()),
CreatedBy: takeFirst(orig.CreatedBy, uuid.New()),
SourceExampleID: takeFirst(orig.SourceExampleID, sql.NullString{}),
HasAITask: orig.HasAITask,
})
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions coderd/database/dbmem/dbmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -9382,6 +9382,7 @@ func (q *FakeQuerier) InsertTemplateVersion(_ context.Context, arg database.Inse
JobID: arg.JobID,
CreatedBy: arg.CreatedBy,
SourceExampleID: arg.SourceExampleID,
HasAITask: arg.HasAITask,
}
q.templateVersions = append(q.templateVersions, version)
return nil
Expand Down Expand Up @@ -10061,6 +10062,7 @@ func (q *FakeQuerier) InsertWorkspaceBuild(_ context.Context, arg database.Inser
MaxDeadline: arg.MaxDeadline,
Reason: arg.Reason,
TemplateVersionPresetID: arg.TemplateVersionPresetID,
HasAITask: arg.HasAITask,
}
q.workspaceBuilds = append(q.workspaceBuilds, workspaceBuild)
return nil
Expand Down
14 changes: 10 additions & 4 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions coderd/database/queries/templateversions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ INSERT INTO
readme,
job_id,
created_by,
source_example_id
source_example_id,
has_ai_task
)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);

-- name: UpdateTemplateVersionByID :exec
UPDATE
Expand Down
5 changes: 3 additions & 2 deletions coderd/database/queries/workspacebuilds.sql
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,11 @@ INSERT INTO
deadline,
max_deadline,
reason,
template_version_preset_id
template_version_preset_id,
has_ai_task
)
VALUES
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14);
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15);

-- name: UpdateWorkspaceBuildCostByID :exec
UPDATE
Expand Down
3 changes: 3 additions & 0 deletions coderd/templateversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,9 @@ func (api *API) postTemplateVersionsByOrganization(rw http.ResponseWriter, r *ht
String: req.ExampleID,
Valid: req.ExampleID != "",
},
// appease the exhaustruct linter
// TODO: set this to whether the template version defines a `coder_ai_task` tf resource
HasAITask: false,
})
if err != nil {
if database.IsUniqueViolation(err, database.UniqueTemplateVersionsTemplateIDNameKey) {
Expand Down
3 changes: 3 additions & 0 deletions coderd/wsbuilder/wsbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@ func (b *Builder) buildTx(authFunc func(action policy.Action, object rbac.Object
UUID: b.templateVersionPresetID,
Valid: b.templateVersionPresetID != uuid.Nil,
},
// appease the exhaustruct linter
// TODO: set this to whether the build included a `coder_ai_task` tf resource
HasAITask: false,
})
if err != nil {
code := http.StatusInternalServerError
Expand Down
Loading