feat!: remove has_ai_task and the task build reasons (#29085)
Drops the `has_ai_task` column from `template_versions` and `workspace_builds` (with its index and view projections) and removes the three task build reasons (`task_auto_pause`, `task_manual_pause`, `task_resume`) from the `build_reason` enum. Existing rows are remapped before the enum swap: automatic pauses become `autostop`, manual pauses and resumes become `initiator`, and `workspace_build_orchestrations.child_reason` follows the same mapping. The query filters, provisionerdserver flag writes, and audit ignore entries for the column go with it. **Migration cost:** recreating `build_reason` rewrites `workspace_builds`. `TestMigration000593TaskBuildReasonRewriteTiming` seeds 1,000 workspaces, 100,000 builds (30,000 with task reasons) and 5,000 orchestrations and asserts the migration stays under a two-minute bound; locally it takes about 0.7 to 1.0 s. The test is skipped under `-short`. **Breaking change:** the down migration re-adds `has_ai_task` as `false` and restores the enum values; remapped reasons keep their new values. **Review changes:** the migration test now asserts only the row remaps (schema and enum introspection removed per review); renumbered from 000592 to 000593. **Stack context:** Coder Tasks removal stack (CODAGT-642): #28743 frontend → #28788 CLI → #28789 API → #28790 provisioner → #29084 notifications → **#29085 build reasons** → #29086 tables → #28750 permissions. The last four PRs replace the single data-drop migration that used to live in #28750; each carries one concern and its own migration number. > Created by Xum (AI agent) on behalf of @ibetitsmike.
This commit is contained in:
1 parent
f809776229
commit
25af21b5d5
18 files changed
+516
-179
No files matched your search
@@ -8335,7 +8335,7 @@ func (q *querier) UpdateTemplateVersionExternalAuthProvidersByJobID(ctx context.
|
||||
}
|
||||
|
||||
func (q *querier) UpdateTemplateVersionFlagsByJobID(ctx context.Context, arg database.UpdateTemplateVersionFlagsByJobIDParams) error {
|
||||
// An actor is allowed to update the template version ai task and external agent flag if they are authorized to update the template.
|
||||
// An actor is allowed to update the template version external agent flag if they are authorized to update the template.
|
||||
tv, err := q.db.GetTemplateVersionByJobID(ctx, arg.JobID)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -2906,7 +2906,7 @@ func (s *MethodTestSuite) TestTemplate() {
|
||||
s.Run("UpdateTemplateVersionFlagsByJobID", s.Mocked(func(dbm *dbmock.MockStore, faker *gofakeit.Faker, check *expects) {
|
||||
t := testutil.Fake(s.T(), faker, database.Template{})
|
||||
tv := testutil.Fake(s.T(), faker, database.TemplateVersion{TemplateID: uuid.NullUUID{UUID: t.ID, Valid: true}})
|
||||
arg := database.UpdateTemplateVersionFlagsByJobIDParams{JobID: tv.JobID, HasAITask: sql.NullBool{Bool: true, Valid: true}, HasExternalAgent: sql.NullBool{Bool: true, Valid: true}}
|
||||
arg := database.UpdateTemplateVersionFlagsByJobIDParams{JobID: tv.JobID, HasExternalAgent: sql.NullBool{Bool: true, Valid: true}}
|
||||
dbm.EXPECT().GetTemplateVersionByJobID(gomock.Any(), tv.JobID).Return(tv, nil).AnyTimes()
|
||||
dbm.EXPECT().GetTemplateByID(gomock.Any(), t.ID).Return(t, nil).AnyTimes()
|
||||
dbm.EXPECT().UpdateTemplateVersionFlagsByJobID(gomock.Any(), arg).Return(nil).AnyTimes()
|
||||
@@ -4453,7 +4453,6 @@ func (s *MethodTestSuite) TestWorkspace() {
|
||||
dbm.EXPECT().UpdateWorkspaceBuildFlagsByID(gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
|
||||
check.Args(database.UpdateWorkspaceBuildFlagsByIDParams{
|
||||
ID: b.ID,
|
||||
HasAITask: sql.NullBool{Bool: true, Valid: true},
|
||||
HasExternalAgent: sql.NullBool{Bool: true, Valid: true},
|
||||
UpdatedAt: b.UpdatedAt,
|
||||
}).Asserts(w, policy.ActionUpdate)
|
||||
|
||||
Reference in new issue
Block a user