mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
chore: allow multiple agent subsystems, add exectrace (#8933)
This commit is contained in:
@ -0,0 +1,17 @@
|
||||
BEGIN;
|
||||
|
||||
-- Bring back the subsystem column.
|
||||
ALTER TABLE workspace_agents ADD COLUMN subsystem workspace_agent_subsystem NOT NULL DEFAULT 'none';
|
||||
|
||||
-- Update all existing workspace_agents to have subsystem = subsystems[0] unless
|
||||
-- subsystems is empty.
|
||||
UPDATE workspace_agents SET subsystem = subsystems[1] WHERE cardinality(subsystems) > 0;
|
||||
|
||||
-- Drop the subsystems column from workspace_agents.
|
||||
ALTER TABLE workspace_agents DROP COLUMN subsystems;
|
||||
|
||||
-- We cannot drop the "exectrace" value from the workspace_agent_subsystem type
|
||||
-- because you cannot drop values from an enum type.
|
||||
UPDATE workspace_agents SET subsystem = 'none' WHERE subsystem = 'exectrace';
|
||||
|
||||
COMMIT;
|
@ -0,0 +1,21 @@
|
||||
BEGIN;
|
||||
|
||||
-- Add "exectrace" to workspace_agent_subsystem type.
|
||||
ALTER TYPE workspace_agent_subsystem ADD VALUE 'exectrace';
|
||||
|
||||
-- Create column subsystems in workspace_agents table, with default value being
|
||||
-- an empty array.
|
||||
ALTER TABLE workspace_agents ADD COLUMN subsystems workspace_agent_subsystem[] DEFAULT '{}';
|
||||
|
||||
-- Add a constraint that the subsystems cannot contain the deprecated value
|
||||
-- 'none'.
|
||||
ALTER TABLE workspace_agents ADD CONSTRAINT subsystems_not_none CHECK (NOT ('none' = ANY (subsystems)));
|
||||
|
||||
-- Update all existing workspace_agents to have subsystems = [subsystem] unless
|
||||
-- the subsystem is 'none'.
|
||||
UPDATE workspace_agents SET subsystems = ARRAY[subsystem] WHERE subsystem != 'none';
|
||||
|
||||
-- Drop the subsystem column from workspace_agents.
|
||||
ALTER TABLE workspace_agents DROP COLUMN subsystem;
|
||||
|
||||
COMMIT;
|
Reference in New Issue
Block a user