34 lines
951 B
PHP
34 lines
951 B
PHP
<?php
|
|
// Generated by setup_mariadb_project.sh — edit as needed.
|
|
define('DB_HOST', '127.0.0.1');
|
|
define('DB_NAME', 'app_36908');
|
|
define('DB_USER', 'app_36908');
|
|
define('DB_PASS', 'bb57422b-2adb-4345-b6c0-d51adb20590a');
|
|
|
|
function db() {
|
|
static $pdo;
|
|
if (!$pdo) {
|
|
$pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_NAME.';charset=utf8mb4', DB_USER, DB_PASS, [
|
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
|
]);
|
|
}
|
|
return $pdo;
|
|
}
|
|
|
|
function run_migrations() {
|
|
$pdo = db();
|
|
$migration_file = __DIR__ . '/migrations/001_initial_schema.sql';
|
|
if (file_exists($migration_file)) {
|
|
try {
|
|
$sql = file_get_contents($migration_file);
|
|
$pdo->exec($sql);
|
|
} catch (PDOException $e) {
|
|
// Optional: log error without crashing
|
|
error_log("Migration failed: " . $e->getMessage());
|
|
}
|
|
}
|
|
}
|
|
|
|
run_migrations();
|