24 lines
628 B
PHP
24 lines
628 B
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
// This script will run all migrations and then delete itself.
|
|
|
|
$pdo = db();
|
|
$migrations_dir = __DIR__ . '/db/migrations';
|
|
$files = glob($migrations_dir . '/*.sql');
|
|
|
|
foreach ($files as $file) {
|
|
$sql = file_get_contents($file);
|
|
try {
|
|
$pdo->exec($sql);
|
|
echo "Successfully ran migration: " . basename($file) . "<br>";
|
|
} catch (PDOException $e) {
|
|
echo "Error running migration: " . basename($file) . " - " . $e->getMessage() . "<br>";
|
|
}
|
|
}
|
|
|
|
// Self-destruct
|
|
unlink(__FILE__);
|
|
|
|
echo "<br>All migrations have been processed. This script has been deleted.";
|