37 lines
898 B
PHP
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";
|
|
|