<?php
declare(strict_types=1);

return function (\App\Core\Database $db): void {
    $table = 'death_cases';
    $col = 'children_assignment_json';

    $exists = $db->selectOne(
        "SELECT 1 FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = ? AND column_name = ?",
        [$table, $col]
    );

    if (!$exists) {
        $db->raw("ALTER TABLE `{$table}` ADD COLUMN `{$col}` JSON NULL AFTER `primary_spouse_form_filled`");
    }
};
