23 lines
692 B
PHP
23 lines
692 B
PHP
<?php
|
|
require 'app/bootstrap.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);
|
|
}
|