25 lines
572 B
PHP
25 lines
572 B
PHP
<?php
|
|
// Simple migration script
|
|
require_once __DIR__ . '/config.php';
|
|
|
|
try {
|
|
$pdo = db();
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
|
|
$migrationsDir = __DIR__ . '/migrations';
|
|
$files = glob($migrationsDir . '/*.sql');
|
|
sort($files);
|
|
|
|
foreach ($files as $file) {
|
|
echo "Running migration: " . basename($file) . "\n";
|
|
$sql = file_get_contents($file);
|
|
$pdo->exec($sql);
|
|
}
|
|
|
|
echo "Migrations completed successfully.\n";
|
|
|
|
} catch (PDOException $e) {
|
|
die("Migration failed: " . $e->getMessage());
|
|
}
|
|
|