<?php
require_once __DIR__ . '/../../public/vendor/autoload.php';

use App\Config\Database;

$sqlFile = __DIR__ . '/016_add_phone_field_to_dynamic_form_fields.sql';
if (!file_exists($sqlFile)) {
    echo "SQL file not found: $sqlFile\n";
    exit(1);
}
$sql = file_get_contents($sqlFile);
if (trim($sql) === '') {
    echo "SQL file is empty\n";
    exit(1);
}

$db = Database::getInstance()->getConnection();
try {
    $db->exec($sql);
    echo "Migration 016 applied successfully.\n";
} catch (PDOException $e) {
    echo "Migration failed: " . $e->getMessage() . "\n";
    exit(1);
}
