36526-vm/db/migrate.php
2025-12-01 07:41:47 +00:00

21 lines
516 B
PHP

<?php
require_once __DIR__ . '/../config.php';
try {
$pdo = db();
echo "<p>Connected to database successfully.</p>";
$sqlFile = __DIR__ . '/migrations/001_initial_schema.sql';
if (!file_exists($sqlFile)) {
die("<p>Migration file not found: $sqlFile</p>");
}
$sql = file_get_contents($sqlFile);
$pdo->exec($sql);
echo "<p>Database migration completed successfully!</p>";
} catch (PDOException $e) {
die("<p>Database operation failed: " . $e->getMessage() . "</p>");
}