bmc_hub/migrations/067_add_regex_action.sql

31 lines
1.4 KiB
MySQL
Raw Normal View History

-- Add Regex Extract and Link Action
-- Allows configurable regex extraction and database linking workflows
INSERT INTO email_workflow_actions (action_code, name, description, category, parameter_schema, example_config)
VALUES (
'regex_extract_and_link',
'Regex Ekstrahering & Linking',
'Søg efter mønstre (Regex) og link email til database matches',
'linking',
'{
"type": "object",
"properties": {
"regex_pattern": {"type": "string", "title": "Regex Pattern (med 1 gruppe)"},
"target_table": {"type": "string", "enum": ["customers", "vendors", "users"], "title": "Tabel"},
"target_column": {"type": "string", "title": "Søge Kolonne"},
"link_column": {"type": "string", "title": "Link Kolonne i Email", "default": "customer_id"},
"value_column": {"type": "string", "title": "Værdi Kolonne", "default": "id"},
"on_match": {"type": "string", "enum": ["update_email", "none"], "default": "update_email", "title": "Handling"}
},
"required": ["regex_pattern", "target_table", "target_column"]
}',
'{
"regex_pattern": "CVR-nr\\.?:?\\s*(\\d{8})",
"target_table": "customers",
"target_column": "cvr_number",
"link_column": "customer_id",
"value_column": "id",
"on_match": "update_email"
}'
) ON CONFLICT (action_code) DO NOTHING;