24 lines
547 B
PHP
24 lines
547 B
PHP
<?php
|
|
require_once __DIR__ . '/config.php';
|
|
|
|
try {
|
|
$pdo = db();
|
|
echo "Connected to database successfully.\n";
|
|
|
|
$migration_files = glob(__DIR__ . '/migrations/*.sql');
|
|
sort($migration_files);
|
|
|
|
foreach ($migration_files as $file) {
|
|
echo "Applying migration: " . basename($file) . "...\n";
|
|
$sql = file_get_contents($file);
|
|
$pdo->exec($sql);
|
|
echo "Applied successfully.\n";
|
|
}
|
|
|
|
echo "All migrations applied.\n";
|
|
|
|
} catch (PDOException $e) {
|
|
die("Database error: " . $e->getMessage());
|
|
}
|
|
|