29 lines
831 B
PHP
29 lines
831 B
PHP
<?php
|
|
require_once __DIR__ . '/config.php';
|
|
|
|
function run_migrations() {
|
|
$pdo = db_connect();
|
|
$migration_files = glob(__DIR__ . '/migrations/*.sql');
|
|
sort($migration_files);
|
|
|
|
foreach ($migration_files as $file) {
|
|
$sql = file_get_contents($file);
|
|
$pdo->exec($sql);
|
|
echo "Applied migration: " . basename($file) . "\n";
|
|
}
|
|
}
|
|
|
|
run_migrations();
|
|
|
|
// Add a default admin user
|
|
$pdo = db_connect();
|
|
$stmt = $pdo->prepare("SELECT id FROM users WHERE email = ?");
|
|
$stmt->execute(['admin@university.com']);
|
|
if (!$stmt->fetch()) {
|
|
$password = password_hash('password', PASSWORD_DEFAULT);
|
|
$stmt = $pdo->prepare("INSERT INTO users (email, password, role) VALUES (?, ?, ?)");
|
|
$stmt->execute(['admin@university.com', $password, 'Super Admin']);
|
|
echo "Created default admin user.\n";
|
|
}
|
|
|
|
?>
|