import pool from '../../db.js'; const CREATE_NOTIFICATIONS_TABLE = ` CREATE TABLE IF NOT EXISTS tab_scheduling_notifications ( id BIGINT PRIMARY KEY AUTO_INCREMENT, suggestion_id VARCHAR(128) NOT NULL, current_plate VARCHAR(32) NOT NULL, candidate_plate VARCHAR(32) NOT NULL, operator_id VARCHAR(64), operator_name VARCHAR(128), status VARCHAR(16) NOT NULL DEFAULT 'sent', created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, executed_at DATETIME NULL, notes VARCHAR(500) NULL, before_mileage INT NULL, after_mileage INT NULL, INDEX idx_suggestion_id (suggestion_id), INDEX idx_current_plate (current_plate), INDEX idx_candidate_plate (candidate_plate), INDEX idx_status (status), INDEX idx_created_at (created_at) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='智能调度干预/执行记录' `; export async function ensureSchedulingTables(): Promise { try { await pool.query(CREATE_NOTIFICATIONS_TABLE); console.log('[scheduling] notifications table ready'); } catch (e) { console.error('[scheduling] failed to ensure tables:', e); throw e; } }