Basdat/database/migration_ai_chat.sql
2025-12-20 00:01:08 +07:00

16 lines
784 B
SQL

CREATE TABLE IF NOT EXISTS chat_messages (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
user_id INT UNSIGNED NOT NULL,
message TEXT NOT NULL,
response TEXT NOT NULL,
context_data JSON DEFAULT NULL COMMENT 'Data konteks (items, lost_items, dll)',
intent VARCHAR(50) DEFAULT NULL COMMENT 'search_item, report_lost, claim_help, general',
confidence_score DECIMAL(5,2) DEFAULT 0.00,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
INDEX idx_chat_user_id (user_id),
INDEX idx_chat_intent (intent),
INDEX idx_chat_created_at (created_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SELECT '✅ AI Chat table created successfully!' AS Status;