CREATE TABLE IF NOT EXISTS pin_comments (
  id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
  pin_key VARCHAR(191) NOT NULL,
  province CHAR(2) NULL,
  author_user_id BIGINT UNSIGNED NOT NULL,
  text VARCHAR(1200) NOT NULL,
  condition_rating TINYINT UNSIGNED NULL,
  status ENUM('active','hidden','flagged') NOT NULL DEFAULT 'active',
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  CONSTRAINT fk_pin_comments_user FOREIGN KEY (author_user_id) REFERENCES users(id) ON DELETE CASCADE,
  INDEX idx_pin_comments_pin_created (pin_key, created_at),
  INDEX idx_pin_comments_status (status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
