27 lines
769 B
PHP
27 lines
769 B
PHP
<?php
|
|
// db/migrations/001_create_users_table.php
|
|
|
|
if (function_exists('migrate_001_create_users_table')) {
|
|
return;
|
|
}
|
|
|
|
function migrate_001_create_users_table() {
|
|
require_once __DIR__ . '/../config.php';
|
|
|
|
try {
|
|
$pdo = db();
|
|
$sql = "
|
|
CREATE TABLE IF NOT EXISTS users (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
username VARCHAR(50) NOT NULL UNIQUE,
|
|
password VARCHAR(255) NOT NULL,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
|
";
|
|
$pdo->exec($sql);
|
|
echo "Migration 001: 'users' table created or already exists.\n";
|
|
} catch (PDOException $e) {
|
|
die("Migration 001 failed: " . $e->getMessage() . "\n");
|
|
}
|
|
}
|