Skip to content

Commit fa86cc4

Browse files
authored
chore: support the has_ai_task column in template version and workspace insert queries (#18385)
#18359 added the `has_ai_task` columns on the `workspace_builds` and `template_versions` tables.
1 parent d562466 commit fa86cc4

File tree

7 files changed

+26
-8
lines changed

7 files changed

+26
-8
lines changed

coderd/database/dbgen/dbgen.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ func WorkspaceBuild(t testing.TB, db database.Store, orig database.WorkspaceBuil
369369
UUID: uuid.UUID{},
370370
Valid: false,
371371
}),
372+
HasAITask: orig.HasAITask,
372373
})
373374
if err != nil {
374375
return err
@@ -943,6 +944,7 @@ func TemplateVersion(t testing.TB, db database.Store, orig database.TemplateVers
943944
JobID: takeFirst(orig.JobID, uuid.New()),
944945
CreatedBy: takeFirst(orig.CreatedBy, uuid.New()),
945946
SourceExampleID: takeFirst(orig.SourceExampleID, sql.NullString{}),
947+
HasAITask: orig.HasAITask,
946948
})
947949
if err != nil {
948950
return err

coderd/database/dbmem/dbmem.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9382,6 +9382,7 @@ func (q *FakeQuerier) InsertTemplateVersion(_ context.Context, arg database.Inse
93829382
JobID: arg.JobID,
93839383
CreatedBy: arg.CreatedBy,
93849384
SourceExampleID: arg.SourceExampleID,
9385+
HasAITask: arg.HasAITask,
93859386
}
93869387
q.templateVersions = append(q.templateVersions, version)
93879388
return nil
@@ -10061,6 +10062,7 @@ func (q *FakeQuerier) InsertWorkspaceBuild(_ context.Context, arg database.Inser
1006110062
MaxDeadline: arg.MaxDeadline,
1006210063
Reason: arg.Reason,
1006310064
TemplateVersionPresetID: arg.TemplateVersionPresetID,
10065+
HasAITask: arg.HasAITask,
1006410066
}
1006510067
q.workspaceBuilds = append(q.workspaceBuilds, workspaceBuild)
1006610068
return nil

coderd/database/queries.sql.go

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/templateversions.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ INSERT INTO
8888
readme,
8989
job_id,
9090
created_by,
91-
source_example_id
91+
source_example_id,
92+
has_ai_task
9293
)
9394
VALUES
94-
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11);
95+
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12);
9596

9697
-- name: UpdateTemplateVersionByID :exec
9798
UPDATE

coderd/database/queries/workspacebuilds.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,11 @@ INSERT INTO
121121
deadline,
122122
max_deadline,
123123
reason,
124-
template_version_preset_id
124+
template_version_preset_id,
125+
has_ai_task
125126
)
126127
VALUES
127-
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14);
128+
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15);
128129

129130
-- name: UpdateWorkspaceBuildCostByID :exec
130131
UPDATE

coderd/templateversions.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,9 @@ func (api *API) postTemplateVersionsByOrganization(rw http.ResponseWriter, r *ht
17301730
String: req.ExampleID,
17311731
Valid: req.ExampleID != "",
17321732
},
1733+
// appease the exhaustruct linter
1734+
// TODO: set this to whether the template version defines a `coder_ai_task` tf resource
1735+
HasAITask: false,
17331736
})
17341737
if err != nil {
17351738
if database.IsUniqueViolation(err, database.UniqueTemplateVersionsTemplateIDNameKey) {

coderd/wsbuilder/wsbuilder.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,9 @@ func (b *Builder) buildTx(authFunc func(action policy.Action, object rbac.Object
425425
UUID: b.templateVersionPresetID,
426426
Valid: b.templateVersionPresetID != uuid.Nil,
427427
},
428+
// appease the exhaustruct linter
429+
// TODO: set this to whether the build included a `coder_ai_task` tf resource
430+
HasAITask: false,
428431
})
429432
if err != nil {
430433
code := http.StatusInternalServerError

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy