Files
windmill/backend/migrations/20260124172000_grouped_workspace_settings.up.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

60 lines
2.7 KiB
SQL

-- Step 1: Add error_handler_muted_on_user_path column if it doesn't exist (was previously a separate migration)
ALTER TABLE workspace_settings ADD COLUMN IF NOT EXISTS error_handler_muted_on_user_path BOOL NOT NULL DEFAULT false;
-- Step 2: Add new JSONB columns with temporary names (to avoid collision with existing TEXT columns)
ALTER TABLE workspace_settings
ADD COLUMN IF NOT EXISTS auto_invite JSONB,
ADD COLUMN IF NOT EXISTS error_handler_new JSONB,
ADD COLUMN IF NOT EXISTS success_handler_new JSONB;
-- Step 3: Migrate existing data to new columns (use jsonb_strip_nulls to omit null values)
UPDATE workspace_settings SET
auto_invite = jsonb_strip_nulls(jsonb_build_object(
'enabled', auto_invite_domain IS NOT NULL,
'domain', auto_invite_domain,
'operator', COALESCE(auto_invite_operator, false),
'mode', CASE WHEN auto_add THEN 'add' ELSE 'invite' END,
'instance_groups', CASE WHEN auto_add_instance_groups IS NOT NULL THEN to_jsonb(auto_add_instance_groups) ELSE NULL END,
'instance_groups_roles', auto_add_instance_groups_roles
)),
error_handler_new = CASE
WHEN error_handler IS NOT NULL THEN jsonb_strip_nulls(jsonb_build_object(
'path', error_handler,
'extra_args', error_handler_extra_args::jsonb,
'muted_on_cancel', error_handler_muted_on_cancel,
'muted_on_user_path', error_handler_muted_on_user_path
))
ELSE NULL
END,
success_handler_new = CASE
WHEN success_handler IS NOT NULL THEN jsonb_strip_nulls(jsonb_build_object(
'path', success_handler,
'extra_args', success_handler_extra_args::jsonb
))
ELSE NULL
END;
-- Step 4: Drop old columns that are now consolidated
ALTER TABLE workspace_settings
DROP COLUMN IF EXISTS auto_invite_domain,
DROP COLUMN IF EXISTS auto_invite_operator,
DROP COLUMN IF EXISTS auto_add,
DROP COLUMN IF EXISTS auto_add_instance_groups,
DROP COLUMN IF EXISTS auto_add_instance_groups_roles,
DROP COLUMN IF EXISTS error_handler,
DROP COLUMN IF EXISTS error_handler_extra_args,
DROP COLUMN IF EXISTS error_handler_muted_on_cancel,
DROP COLUMN IF EXISTS error_handler_muted_on_user_path,
DROP COLUMN IF EXISTS success_handler,
DROP COLUMN IF EXISTS success_handler_extra_args;
-- Step 5: Rename new columns to their final names
ALTER TABLE workspace_settings
RENAME COLUMN error_handler_new TO error_handler;
ALTER TABLE workspace_settings
RENAME COLUMN success_handler_new TO success_handler;
-- Step 6: Add GIN index on auto_invite for efficient JSONB queries (e.g., ? operator for instance_groups)
-- Using default GIN opclass (not jsonb_path_ops) to support the ? operator
CREATE INDEX IF NOT EXISTS idx_workspace_settings_auto_invite ON workspace_settings USING GIN (auto_invite);