feat: admin complaint (owner only) + result appeal (one per ticket, owner only)

This commit is contained in:
2026-07-12 15:19:09 +08:00
parent 6657c05dec
commit 10b6ff94ed
5 changed files with 72 additions and 9 deletions

View File

@@ -84,7 +84,7 @@ async function initSchema(connection) {
await createIfNotExists('tickets', `CREATE TABLE tickets (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT,
type ENUM('report','suggestion','appeal') NOT NULL,
type ENUM('report','suggestion','appeal','result_appeal') NOT NULL,
title VARCHAR(100) NOT NULL,
status ENUM('pending','processing','awaiting_info','resolved','rejected','closed') NOT NULL DEFAULT 'pending',
priority ENUM('low','medium','high','urgent') NOT NULL DEFAULT 'medium',
@@ -98,6 +98,8 @@ async function initSchema(connection) {
claim_note TEXT,
claimed_at DATETIME,
tracking_token VARCHAR(255) UNIQUE,
is_admin_complaint TINYINT(1) NOT NULL DEFAULT 0,
parent_ticket_id INT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX idx_type (type),
@@ -185,6 +187,13 @@ async function initSchema(connection) {
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4`);
await seedTemplates(db);
await migrateAdditions(db);
}
async function migrateAdditions(db) {
try { await db.execute("ALTER TABLE tickets ADD COLUMN is_admin_complaint TINYINT(1) NOT NULL DEFAULT 0"); } catch {}
try { await db.execute("ALTER TABLE tickets ADD COLUMN parent_ticket_id INT"); } catch {}
try { await db.execute("ALTER TABLE tickets MODIFY type ENUM('report','suggestion','appeal','result_appeal') NOT NULL"); } catch {}
}
async function seedTemplates(db) {