CREATE TABLE IF NOT EXISTS facebook_question_queue (
 id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
 facebook_group_id BIGINT UNSIGNED NOT NULL,
 source_post_id BIGINT UNSIGNED NULL,
 source_key CHAR(64) NOT NULL,
 post_url TEXT NULL,
 author_label VARCHAR(190) NULL,
 question_text TEXT NOT NULL,
 classification ENUM('question','resource','experience','fact_check','event','support','sensitive') NOT NULL DEFAULT 'question',
 relevance_score TINYINT UNSIGNED NOT NULL DEFAULT 0,
 rationale VARCHAR(500) NOT NULL DEFAULT '',
 proposed_answer TEXT NOT NULL,
 status ENUM('proposed','validated','rewrite','ignored','sent') NOT NULL DEFAULT 'proposed',
 decision_reason VARCHAR(500) NULL,
 detected_at DATETIME NOT NULL,
 updated_at DATETIME NOT NULL,
 UNIQUE KEY facebook_question_source(source_key),
 INDEX facebook_question_workflow(status,relevance_score),
 INDEX facebook_question_group(facebook_group_id,detected_at),
 CONSTRAINT fk_facebook_question_group FOREIGN KEY(facebook_group_id) REFERENCES facebook_groups(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
