37338-vm/db/migrations/034_add_guest_survey_follow_up_process.php
2026-01-11 12:14:53 +00:00

66 lines
1.8 KiB
PHP

<?php
require_once __DIR__ . '/../../db/config.php';
function migrate_034()
{
$pdo = db();
$process_name = 'Guest Survey Follow-up';
$process_code = 'guest_survey_follow_up';
$json_definition = <<<'EOT'
{
"start_node_id": "follow_up",
"nodes": {
"follow_up": {
"ui_hints": {
"title": "Follow-up with Guest",
"status": "active",
"reason": "Follow-up with the guest based on their survey feedback.",
"next_step": "Log the outcome of the follow-up.",
"form_schema": [
{ "name": "follow_up_date", "label": "Follow-up Date", "type": "datetime-local", "default": "now", "required": true },
{ "name": "note", "label": "Notes", "type": "textarea" }
]
}
},
"end": {
"ui_hints": {
"title": "Process Ended",
"status": "completed",
"reason": "Follow-up completed.",
"next_step": ""
}
}
},
"transitions": [
{
"id": "complete_follow_up",
"from": "follow_up",
"to": "end",
"name": "Complete Follow-up"
}
]
}
EOT;
$stmt = $pdo->prepare("INSERT INTO process_definitions (name, code, definition_json, is_active, sort_order) VALUES (:name, :code, :json, 1, 99)");
$stmt->execute([
':name' => $process_name,
':code' => $process_code,
':json' => $json_definition,
]);
echo "Migration 034 executed successfully: Added 'Guest Survey Follow-up' process definition.";
}
if (basename(__FILE__) == basename($_SERVER["SCRIPT_FILENAME"]))
{
try {
migrate_034();
} catch (Exception $e) {
echo "Migration 34 failed: " . $e->getMessage() . "\n";
}
}