33951-vm/db/migrate.php
Flatlogic Bot 0a0873a371 v2
2025-09-09 15:57:31 +00:00

28 lines
642 B
PHP

<?php
// Simple migration script
// 1. Load DB configuration
require_once 'config.php';
try {
// 2. Get a PDO database connection
$pdo = db();
// 3. Read the initial schema
$sql = file_get_contents(__DIR__ . '/migrations/001_initial_schema.sql');
if ($sql === false) {
throw new Exception("Error: Could not read the migration file.");
}
// 4. Execute the SQL
$pdo->exec($sql);
echo "Success: Database schema applied successfully." . PHP_EOL;
} catch (PDOException $e) {
die("Error: Database connection failed: " . $e->getMessage());
} catch (Exception $e) {
die($e->getMessage());
}