-- App version check table
DROP TABLE IF EXISTS `app_version`;
CREATE TABLE `app_version` (
  `id` int NOT NULL AUTO_INCREMENT,
  `av_id` varchar(30) NOT NULL COMMENT 'version ID',
  `version_code` int NOT NULL COMMENT 'e.g. 100',
  `version_name` varchar(20) NOT NULL COMMENT 'e.g. 1.0.0',
  `download_url` varchar(500) NOT NULL COMMENT 'APK download URL',
  `force_update` tinyint DEFAULT 0 COMMENT '0=optional 1=force',
  `update_message` text COMMENT 'update description',
  `platform` varchar(10) DEFAULT 'android' COMMENT 'android/ios',
  `status_cd` varchar(2) DEFAULT '0',
  `create_time` timestamp DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `idx_platform` (`platform`, `status_cd`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Seed data: current version
INSERT INTO `app_version` (`av_id`, `version_code`, `version_name`, `download_url`, `force_update`, `update_message`, `platform`, `status_cd`)
VALUES ('AV20260518001', 100, '1.0.0', 'https://spms.xrparking.cn/app/download', 0, '初始版本', 'android', '0');
INSERT INTO c_service (service_id, service_code, business_type_cd, name, seq, is_instance, url, method, timeout, retry_count, provide_app_id, status_cd)
VALUES ('SVCPROPVER', 'property.checkVersion', 'API', '版本检查', 1, 'CMD', 'http://user-service', 'POST', 60, 3, '8000418002', '0');

INSERT INTO c_route (app_id, service_id, order_type_cd, invoke_limit_times, invoke_model, status_cd)
VALUES ('992020022270580001', 'SVCPROPVER', 'Q', -1, 'S', '0');
