exec($sql); file_put_contents($log_file, $file . PHP_EOL, FILE_APPEND); echo "Migration $file executed successfully.\n"; } catch (PDOException $e) { echo "Error executing migration $file: " . $e->getMessage() . "\n"; // Stop on error return; } } } } echo "All migrations are up to date.\n"; } run_migrations();