34681-vm/db/migrate_005.php
Flatlogic Bot 373e36aedb 0.1
2025-10-05 01:54:26 +00:00

37 lines
898 B
PHP

<?php
require_once __DIR__ . '/config.php';
function run_migration($file) {
$db = db();
$sql = file_get_contents($file);
if ($sql === false) {
die("Error reading migration file: $file\n");
}
// Split the SQL file into individual queries
$queries = explode(';', $sql);
foreach ($queries as $query) {
$query = trim($query);
if (!empty($query)) {
try {
$db->exec($query);
echo "Successfully executed query from $file:\n$query\n\n";
} catch (PDOException $e) {
die("Error executing query from $file: " . $e->getMessage() . "\nQuery:\n$query\n");
}
}
}
}
$migration_files = [
__DIR__ . '/migrations/005_add_premium_features.sql',
];
foreach ($migration_files as $file) {
run_migration($file);
}
echo "Migrations completed successfully!\n";