-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat!: remove has_ai_task and the task build reasons #29085
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
91 changes: 91 additions & 0 deletions
91
coderd/database/migrations/000593_remove_has_ai_task_and_task_build_reasons.down.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| -- Drop views before modifying underlying tables and columns. | ||
| DROP VIEW IF EXISTS template_version_with_user; | ||
| DROP VIEW IF EXISTS workspace_build_with_user; | ||
|
|
||
| -- Recreate has_ai_task columns and index. The dropped values are not | ||
| -- recoverable, so backfill false to satisfy older migrations that restore | ||
| -- NOT NULL on the way further down. | ||
| ALTER TABLE template_versions ADD COLUMN has_ai_task boolean DEFAULT false; | ||
| ALTER TABLE template_versions ALTER COLUMN has_ai_task DROP DEFAULT; | ||
| CREATE INDEX idx_template_versions_has_ai_task ON template_versions USING btree (has_ai_task); | ||
| ALTER TABLE workspace_builds ADD COLUMN has_ai_task boolean DEFAULT false; | ||
| ALTER TABLE workspace_builds ALTER COLUMN has_ai_task DROP DEFAULT; | ||
|
|
||
| -- Recreate build_reason enum with task values. | ||
| ALTER TYPE build_reason RENAME TO build_reason_old; | ||
|
|
||
| CREATE TYPE build_reason AS ENUM ( | ||
| 'initiator', | ||
| 'autostart', | ||
| 'autostop', | ||
| 'dormancy', | ||
| 'failedstop', | ||
| 'autodelete', | ||
| 'dashboard', | ||
| 'cli', | ||
| 'ssh_connection', | ||
| 'vscode_connection', | ||
| 'jetbrains_connection', | ||
| 'task_auto_pause', | ||
| 'task_manual_pause', | ||
| 'task_resume' | ||
| ); | ||
|
|
||
| ALTER TABLE workspace_builds ALTER COLUMN reason DROP DEFAULT; | ||
| ALTER TABLE workspace_builds ALTER COLUMN reason TYPE build_reason USING (reason::text::build_reason); | ||
| ALTER TABLE workspace_builds ALTER COLUMN reason SET DEFAULT 'initiator'::build_reason; | ||
|
|
||
| ALTER TABLE workspace_build_orchestrations ALTER COLUMN child_reason TYPE build_reason USING (child_reason::text::build_reason); | ||
|
|
||
| DROP TYPE build_reason_old; | ||
|
|
||
| -- Recreate views. | ||
| CREATE VIEW template_version_with_user AS | ||
| SELECT template_versions.id, | ||
| template_versions.template_id, | ||
| template_versions.organization_id, | ||
| template_versions.created_at, | ||
| template_versions.updated_at, | ||
| template_versions.name, | ||
| template_versions.readme, | ||
| template_versions.job_id, | ||
| template_versions.created_by, | ||
| template_versions.external_auth_providers, | ||
| template_versions.message, | ||
| template_versions.archived, | ||
| template_versions.source_example_id, | ||
| template_versions.has_ai_task, | ||
| template_versions.has_external_agent, | ||
| COALESCE(visible_users.avatar_url, ''::text) AS created_by_avatar_url, | ||
| COALESCE(visible_users.username, ''::text) AS created_by_username, | ||
| COALESCE(visible_users.name, ''::text) AS created_by_name | ||
| FROM (template_versions | ||
| LEFT JOIN visible_users ON ((template_versions.created_by = visible_users.id))); | ||
|
|
||
| COMMENT ON VIEW template_version_with_user IS 'Joins in the username + avatar url of the created by user.'; | ||
|
|
||
| CREATE VIEW workspace_build_with_user AS | ||
| SELECT workspace_builds.id, | ||
| workspace_builds.created_at, | ||
| workspace_builds.updated_at, | ||
| workspace_builds.workspace_id, | ||
| workspace_builds.template_version_id, | ||
| workspace_builds.build_number, | ||
| workspace_builds.transition, | ||
| workspace_builds.initiator_id, | ||
| workspace_builds.job_id, | ||
| workspace_builds.deadline, | ||
| workspace_builds.reason, | ||
| workspace_builds.daily_cost, | ||
| workspace_builds.max_deadline, | ||
| workspace_builds.template_version_preset_id, | ||
| workspace_builds.has_ai_task, | ||
| workspace_builds.has_external_agent, | ||
| workspace_builds.notified_autostop_deadline, | ||
| COALESCE(visible_users.avatar_url, ''::text) AS initiator_by_avatar_url, | ||
| COALESCE(visible_users.username, ''::text) AS initiator_by_username, | ||
| COALESCE(visible_users.name, ''::text) AS initiator_by_name | ||
| FROM (workspace_builds | ||
| LEFT JOIN visible_users ON ((workspace_builds.initiator_id = visible_users.id))); | ||
|
|
||
| COMMENT ON VIEW workspace_build_with_user IS 'Joins in the username + avatar url of the initiated by user.'; |
99 changes: 99 additions & 0 deletions
99
coderd/database/migrations/000593_remove_has_ai_task_and_task_build_reasons.up.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| DROP VIEW IF EXISTS template_version_with_user; | ||
| DROP VIEW IF EXISTS workspace_build_with_user; | ||
|
|
||
| -- Drop has_ai_task index and columns. | ||
| DROP INDEX IF EXISTS idx_template_versions_has_ai_task; | ||
| ALTER TABLE template_versions DROP COLUMN IF EXISTS has_ai_task; | ||
| ALTER TABLE workspace_builds DROP COLUMN IF EXISTS has_ai_task; | ||
|
|
||
| -- Remove task-related build reasons from build_reason enum. Automatic | ||
| -- pauses stay system-attributed; manual pauses and resumes were created by | ||
| -- authenticated user requests, so they keep user attribution as initiator. | ||
| UPDATE workspace_builds | ||
| SET reason = 'autostop' | ||
| WHERE reason::text = 'task_auto_pause'; | ||
|
|
||
| UPDATE workspace_builds | ||
| SET reason = 'initiator' | ||
| WHERE reason::text IN ('task_manual_pause', 'task_resume'); | ||
|
|
||
| UPDATE workspace_build_orchestrations | ||
| SET child_reason = 'autostop' | ||
| WHERE child_reason::text = 'task_auto_pause'; | ||
|
|
||
| UPDATE workspace_build_orchestrations | ||
| SET child_reason = 'initiator' | ||
| WHERE child_reason::text IN ('task_manual_pause', 'task_resume'); | ||
|
|
||
| ALTER TYPE build_reason RENAME TO build_reason_old; | ||
|
|
||
| CREATE TYPE build_reason AS ENUM ( | ||
| 'initiator', | ||
| 'autostart', | ||
| 'autostop', | ||
| 'dormancy', | ||
| 'failedstop', | ||
| 'autodelete', | ||
| 'dashboard', | ||
| 'cli', | ||
| 'ssh_connection', | ||
| 'vscode_connection', | ||
| 'jetbrains_connection' | ||
| ); | ||
|
|
||
| ALTER TABLE workspace_builds ALTER COLUMN reason DROP DEFAULT; | ||
| ALTER TABLE workspace_builds ALTER COLUMN reason TYPE build_reason USING (reason::text::build_reason); | ||
|
ibetitsmike marked this conversation as resolved.
|
||
| ALTER TABLE workspace_builds ALTER COLUMN reason SET DEFAULT 'initiator'::build_reason; | ||
|
|
||
| ALTER TABLE workspace_build_orchestrations ALTER COLUMN child_reason TYPE build_reason USING (child_reason::text::build_reason); | ||
|
|
||
| DROP TYPE build_reason_old; | ||
|
|
||
| -- Recreate views without task columns. | ||
| CREATE VIEW template_version_with_user AS | ||
| SELECT template_versions.id, | ||
| template_versions.template_id, | ||
| template_versions.organization_id, | ||
| template_versions.created_at, | ||
| template_versions.updated_at, | ||
| template_versions.name, | ||
| template_versions.readme, | ||
| template_versions.job_id, | ||
| template_versions.created_by, | ||
| template_versions.external_auth_providers, | ||
| template_versions.message, | ||
| template_versions.archived, | ||
| template_versions.source_example_id, | ||
| template_versions.has_external_agent, | ||
| COALESCE(visible_users.avatar_url, ''::text) AS created_by_avatar_url, | ||
| COALESCE(visible_users.username, ''::text) AS created_by_username, | ||
| COALESCE(visible_users.name, ''::text) AS created_by_name | ||
| FROM (template_versions | ||
| LEFT JOIN visible_users ON ((template_versions.created_by = visible_users.id))); | ||
|
|
||
| COMMENT ON VIEW template_version_with_user IS 'Joins in the username + avatar url of the created by user.'; | ||
|
|
||
| CREATE VIEW workspace_build_with_user AS | ||
| SELECT workspace_builds.id, | ||
| workspace_builds.created_at, | ||
| workspace_builds.updated_at, | ||
| workspace_builds.workspace_id, | ||
| workspace_builds.template_version_id, | ||
| workspace_builds.build_number, | ||
| workspace_builds.transition, | ||
| workspace_builds.initiator_id, | ||
| workspace_builds.job_id, | ||
| workspace_builds.deadline, | ||
| workspace_builds.reason, | ||
| workspace_builds.daily_cost, | ||
| workspace_builds.max_deadline, | ||
| workspace_builds.template_version_preset_id, | ||
| workspace_builds.has_external_agent, | ||
| workspace_builds.notified_autostop_deadline, | ||
| COALESCE(visible_users.avatar_url, ''::text) AS initiator_by_avatar_url, | ||
| COALESCE(visible_users.username, ''::text) AS initiator_by_username, | ||
| COALESCE(visible_users.name, ''::text) AS initiator_by_name | ||
| FROM (workspace_builds | ||
| LEFT JOIN visible_users ON ((workspace_builds.initiator_id = visible_users.id))); | ||
|
|
||
| COMMENT ON VIEW workspace_build_with_user IS 'Joins in the username + avatar url of the initiated by user.'; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.