Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-02-01 02:28:31 +00:00
parent 7b0ca40c4f
commit 73025c84c5
10 changed files with 413 additions and 87 deletions

View File

@@ -7,10 +7,16 @@ async function createUsersTable() {
username VARCHAR(50) NOT NULL UNIQUE,
name VARCHAR(120) NOT NULL,
email VARCHAR(120) NOT NULL UNIQUE,
is_admin TINYINT(1) NOT NULL DEFAULT 0,
password_hash VARCHAR(255) NOT NULL,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
`);
const [columns] = await db.query(`SHOW COLUMNS FROM users LIKE 'is_admin'`);
if (columns.length === 0) {
await db.query(`ALTER TABLE users ADD COLUMN is_admin TINYINT(1) NOT NULL DEFAULT 0 AFTER email`);
}
}
async function createLicensesTable() {