diff --git a/migrations/migrate.php b/migrations/migrate.php index b34a8b4..b5a1c13 100644 --- a/migrations/migrate.php +++ b/migrations/migrate.php @@ -141,9 +141,12 @@ foreach ($pending as $file) { // DDL. try { // Split by semicolon but respect statements properly - // Note: This doesn't handle semicolons in strings, but our migrations are simple + // Note: This doesn't handle semicolons in strings, but our migrations are simple. + // Full-line "--" comments are stripped first so a ";" inside a comment + // can't cut a statement in half. + $sqlNoComments = preg_replace('/^\s*--.*$/m', '', $sql); $statements = array_values(array_filter( - array_map('trim', explode(';', $sql)), + array_map('trim', explode(';', $sqlNoComments)), function($stmt) { // Remove comments and check if there's actual SQL $cleaned = preg_replace('/--.*$/m', '', $stmt);