feat: Implement ticket commenting functionality

Adds the ability for users to comment on tickets, view comments, and distinguish between user and admin responses. Also introduces a new 'SUSPENDED' status for tickets and refactors database schema and API endpoints to support comments.
This commit is contained in:
2025-12-09 15:58:52 +01:00
parent 4107051585
commit a97dcfa33e
9 changed files with 324 additions and 151 deletions

View File

@@ -334,6 +334,19 @@ const initDb = async () => {
)
`);
// 10. Ticket Comments Table
await connection.query(`
CREATE TABLE IF NOT EXISTS ticket_comments (
id VARCHAR(36) PRIMARY KEY,
ticket_id VARCHAR(36) NOT NULL,
user_id VARCHAR(36) NOT NULL,
text TEXT NOT NULL,
created_at ${TIMESTAMP_TYPE} DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (ticket_id) REFERENCES tickets(id) ON DELETE CASCADE,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
)
`);
// --- SEEDING ---
const [rows] = await connection.query('SELECT * FROM settings WHERE id = 1');
const defaultFeatures = {