Files
musadaq-saas/scratch/run_migration.php
2026-05-07 16:11:36 +03:00

23 lines
716 B
PHP

<?php
require_once __DIR__ . '/../app/bootstrap/init.php';
$sql = file_get_contents('scratch/stage0_db_update.sql');
$db = \App\Core\Database::getInstance()->getConnection();
try {
// MySQL PDO cannot run multiple statements with exec() sometimes depending on driver,
// so we split by semicolon and handle.
$statements = array_filter(array_map('trim', explode(';', $sql)));
foreach ($statements as $stmt) {
if (!empty($stmt)) {
$db->exec($stmt);
echo "Executed: " . substr($stmt, 0, 50) . "...\n";
}
}
echo "Migration completed successfully!\n";
} catch (Exception $e) {
echo "Migration failed: " . $e->getMessage() . "\n";
exit(1);
}