-- -------------------------------------------
-- 开放上传记录
-- -------------------------------------------

CREATE TABLE listing_uploads (
  id BIGINT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
  uploader_name VARCHAR(64) NOT NULL,
  matched_admin_id BIGINT UNSIGNED NULL,
  owner_id BIGINT UNSIGNED NULL,
  client_upload_time DATETIME NULL,
  client_ip VARCHAR(64) NOT NULL DEFAULT '',
  raw_payload JSON NULL,
  parsed_payload JSON NULL,
  listing_id BIGINT UNSIGNED NULL,
  status VARCHAR(32) NOT NULL DEFAULT 'draft_created',
  error_message VARCHAR(255) NOT NULL DEFAULT '',
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  KEY idx_listing_uploads_uploader_name (uploader_name),
  KEY idx_listing_uploads_matched_admin_id (matched_admin_id),
  KEY idx_listing_uploads_owner_id (owner_id),
  KEY idx_listing_uploads_listing_id (listing_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
