CREATE TABLE IF NOT EXISTS {{PREFIX}}trip_checklist_items (
  id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  trip_id BIGINT UNSIGNED NOT NULL,
  user_id BIGINT UNSIGNED NOT NULL,
  title VARCHAR(255) NOT NULL,
  is_done TINYINT(1) NOT NULL DEFAULT 0,
  completed_at DATETIME NULL,
  sort_order INT UNSIGNED NOT NULL DEFAULT 0,
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id),
  KEY idx_trip_checklist_owner (trip_id,user_id,is_done,sort_order),
  CONSTRAINT fk_trip_checklist_trip FOREIGN KEY (trip_id) REFERENCES {{PREFIX}}trips(id) ON DELETE CASCADE,
  CONSTRAINT fk_trip_checklist_user FOREIGN KEY (user_id) REFERENCES {{PREFIX}}users(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
