CREATE TABLE IF NOT EXISTS lingxian_provider_config (
  id BIGINT NOT NULL PRIMARY KEY,
  sys_origin VARCHAR(32) NOT NULL,
  profile VARCHAR(32) NOT NULL DEFAULT 'PROD',
  active TINYINT(1) NOT NULL DEFAULT 1,
  game_list_url VARCHAR(1024) NOT NULL DEFAULT '',
  app_key VARCHAR(255) NOT NULL DEFAULT '',
  test_uid VARCHAR(64) DEFAULT NULL,
  test_token VARCHAR(1024) DEFAULT NULL,
  create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  UNIQUE KEY uk_lingxian_provider_sys_origin_profile (sys_origin, profile),
  KEY idx_lingxian_provider_active (sys_origin, active, update_time)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS lingxian_game_catalog (
  id BIGINT NOT NULL PRIMARY KEY,
  sys_origin VARCHAR(32) NOT NULL,
  profile VARCHAR(32) NOT NULL DEFAULT 'PROD',
  internal_game_id VARCHAR(64) NOT NULL,
  vendor_game_id VARCHAR(64) NOT NULL,
  name VARCHAR(128) NOT NULL,
  cover VARCHAR(1024) DEFAULT NULL,
  preview_url VARCHAR(1024) DEFAULT NULL,
  download_url VARCHAR(1024) DEFAULT NULL,
  package_version VARCHAR(32) DEFAULT NULL,
  raw_json LONGTEXT DEFAULT NULL,
  status VARCHAR(32) NOT NULL DEFAULT 'ENABLED',
  create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  UNIQUE KEY uk_lingxian_catalog_sys_profile_vendor_game (sys_origin, profile, vendor_game_id),
  KEY idx_lingxian_catalog_profile_internal_game (sys_origin, profile, internal_game_id, status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
