24 lines
776 B
PHP
24 lines
776 B
PHP
<?php
|
|
require_once __DIR__ . '/db.php';
|
|
$db = db();
|
|
|
|
// Hent nuværende kolonner
|
|
$cols = $db->query("PRAGMA table_info(users)")->fetchAll(PDO::FETCH_ASSOC);
|
|
$names = array_column($cols, 'name');
|
|
|
|
// Tilføj kolonner hvis de mangler
|
|
if (!in_array('password', $names)) {
|
|
$db->exec("ALTER TABLE users ADD COLUMN password TEXT");
|
|
echo "✅ Tilføjede kolonnen 'password'<br>";
|
|
}
|
|
if (!in_array('password_hash', $names)) {
|
|
$db->exec("ALTER TABLE users ADD COLUMN password_hash TEXT");
|
|
echo "✅ Tilføjede kolonnen 'password_hash'<br>";
|
|
}
|
|
if (!in_array('role', $names)) {
|
|
$db->exec("ALTER TABLE users ADD COLUMN role TEXT DEFAULT 'user'");
|
|
echo "✅ Tilføjede kolonnen 'role'<br>";
|
|
}
|
|
|
|
echo "<br>🎉 Migration fuldført. Du kan nu køre create_admin.php.";
|