CREATE TABLE IF NOT EXISTS messages (
  id VARCHAR(36) PRIMARY KEY DEFAULT (UUID()),
  profile_id VARCHAR(36) NOT NULL,
  user_id INT NOT NULL,
  content TEXT NOT NULL,
  feedback TEXT NULL,
  redo_count INT NOT NULL DEFAULT 0,
  generated_at DATETIME NOT NULL DEFAULT NOW(),
  INDEX idx_messages_profile_id (profile_id),
  INDEX idx_messages_user_id (user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
