34233-vm/db/migrate.php
Flatlogic Bot 4feeb6dacd v2
2025-09-19 20:26:26 +00:00

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());
}