38676-vm/db/migrate_users.php
2026-03-05 00:34:00 +00:00

21 lines
567 B
PHP

<?php
require_once __DIR__ . '/config.php';
$db = db();
$sql = "CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL UNIQUE,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
role VARCHAR(50) DEFAULT 'user',
last_login TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)";
try {
$db->exec($sql);
echo "Table 'users' created successfully.";
} catch (Exception $e) {
echo "Error creating table 'users': " . $e->getMessage();
}