Files
windmill/backend/migrations/20260124172000_grouped_workspace_settings.down.sql
claude[bot] 05fa3cd013 feat: add workspace setting to disable error handler for u/ scripts/flows (#7634)
* feat: add workspace setting to disable error handler for u/ scripts/flows

Add a new workspace setting `error_handler_muted_on_user_path` that allows
disabling the error handler for jobs related to scripts/flows that start
with the "u/" prefix (user scripts/flows).

Changes:
- Add migration to add `error_handler_muted_on_user_path` column to workspace_settings
- Update WorkspaceSettings struct and get_settings query
- Update EditErrorHandler struct and edit_error_handler API endpoint
- Update error handler cache to include the new setting
- Add skip logic in send_error_to_workspace_handler for u/ paths
- Add toggle in workspace settings UI

The implementation uses the existing cached settings to avoid additional
database queries, making it efficient.

Closes #7633

Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>

* all

* update ee private

* combine migrations

* sqlx

* fix: migration fixes for auto_invite JSONB column

- Fix TEXT[] to JSONB conversion using to_jsonb()
- Add GIN index on auto_invite for efficient ? operator queries
- Add index cleanup to down migration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* sqlx

* all

* all

* all

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com>
Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 19:26:06 +00:00

47 lines
2.3 KiB
SQL

-- Step 0: Drop the GIN index on auto_invite
DROP INDEX IF EXISTS idx_workspace_settings_auto_invite;
-- Step 1: Rename current JSONB columns to temporary names to avoid collision
ALTER TABLE workspace_settings
RENAME COLUMN error_handler TO error_handler_jsonb;
ALTER TABLE workspace_settings
RENAME COLUMN success_handler TO success_handler_jsonb;
-- Step 2: Restore old columns with original names and types
ALTER TABLE workspace_settings
ADD COLUMN IF NOT EXISTS auto_invite_domain VARCHAR(255),
ADD COLUMN IF NOT EXISTS auto_invite_operator BOOLEAN,
ADD COLUMN IF NOT EXISTS auto_add BOOLEAN,
ADD COLUMN IF NOT EXISTS auto_add_instance_groups TEXT[],
ADD COLUMN IF NOT EXISTS auto_add_instance_groups_roles JSONB,
ADD COLUMN IF NOT EXISTS error_handler VARCHAR(255),
ADD COLUMN IF NOT EXISTS error_handler_extra_args JSON,
ADD COLUMN IF NOT EXISTS error_handler_muted_on_cancel BOOLEAN DEFAULT false,
ADD COLUMN IF NOT EXISTS error_handler_muted_on_user_path BOOLEAN DEFAULT false,
ADD COLUMN IF NOT EXISTS success_handler TEXT,
ADD COLUMN IF NOT EXISTS success_handler_extra_args JSON;
-- Step 3: Migrate data back from JSONB columns to flat columns
UPDATE workspace_settings SET
auto_invite_domain = auto_invite->>'domain',
auto_invite_operator = COALESCE((auto_invite->>'operator')::boolean, false),
auto_add = (auto_invite->>'mode') = 'add',
auto_add_instance_groups = CASE
WHEN auto_invite->'instance_groups' IS NOT NULL AND auto_invite->'instance_groups' != 'null'::jsonb
THEN ARRAY(SELECT jsonb_array_elements_text(auto_invite->'instance_groups'))
ELSE NULL
END,
auto_add_instance_groups_roles = auto_invite->'instance_groups_roles',
error_handler = error_handler_jsonb->>'path',
error_handler_extra_args = (error_handler_jsonb->'extra_args')::json,
error_handler_muted_on_cancel = COALESCE((error_handler_jsonb->>'muted_on_cancel')::boolean, false),
error_handler_muted_on_user_path = COALESCE((error_handler_jsonb->>'muted_on_user_path')::boolean, false),
success_handler = success_handler_jsonb->>'path',
success_handler_extra_args = (success_handler_jsonb->'extra_args')::json;
-- Step 4: Drop the JSONB columns
ALTER TABLE workspace_settings
DROP COLUMN IF EXISTS auto_invite,
DROP COLUMN IF EXISTS error_handler_jsonb,
DROP COLUMN IF EXISTS success_handler_jsonb;