Skip to content

Commit ebc769f

Browse files
authored
chore: make has_ai_task fields on workspace builds and template versions nullable (#18403)
The fields must be nullable because there’s a period of time between inserting a row into the database and finishing the “plan” provisioner job when the final value of the field is unknown.
1 parent d6df1f2 commit ebc769f

File tree

7 files changed

+27
-10
lines changed

7 files changed

+27
-10
lines changed

coderd/database/dump.sql

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ALTER TABLE template_versions ALTER COLUMN has_ai_task SET DEFAULT false;
2+
ALTER TABLE template_versions ALTER COLUMN has_ai_task SET NOT NULL;
3+
ALTER TABLE workspace_builds ALTER COLUMN has_ai_task SET DEFAULT false;
4+
ALTER TABLE workspace_builds ALTER COLUMN has_ai_task SET NOT NULL;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- The fields must be nullable because there's a period of time between
2+
-- inserting a row into the database and finishing the "plan" provisioner job
3+
-- when the final value of the field is unknown.
4+
ALTER TABLE template_versions ALTER COLUMN has_ai_task DROP DEFAULT;
5+
ALTER TABLE template_versions ALTER COLUMN has_ai_task DROP NOT NULL;
6+
ALTER TABLE workspace_builds ALTER COLUMN has_ai_task DROP DEFAULT;
7+
ALTER TABLE workspace_builds ALTER COLUMN has_ai_task DROP NOT NULL;

coderd/database/models.go

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

coderd/database/queries.sql.go

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

coderd/templateversions.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1732,7 +1732,10 @@ func (api *API) postTemplateVersionsByOrganization(rw http.ResponseWriter, r *ht
17321732
},
17331733
// appease the exhaustruct linter
17341734
// TODO: set this to whether the template version defines a `coder_ai_task` tf resource
1735-
HasAITask: false,
1735+
HasAITask: sql.NullBool{
1736+
Bool: false,
1737+
Valid: false,
1738+
},
17361739
})
17371740
if err != nil {
17381741
if database.IsUniqueViolation(err, database.UniqueTemplateVersionsTemplateIDNameKey) {

coderd/wsbuilder/wsbuilder.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,10 @@ func (b *Builder) buildTx(authFunc func(action policy.Action, object rbac.Object
427427
},
428428
// appease the exhaustruct linter
429429
// TODO: set this to whether the build included a `coder_ai_task` tf resource
430-
HasAITask: false,
430+
HasAITask: sql.NullBool{
431+
Bool: false,
432+
Valid: false,
433+
},
431434
})
432435
if err != nil {
433436
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