Software
v0.0..1
This commit is contained in:
23
software/v0.0.1/web/migrate_users.php
Normal file
23
software/v0.0.1/web/migrate_users.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?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.";
|
||||
Reference in New Issue
Block a user