|
|
@@ -1,51 +1,58 @@
|
|
|
-- VPP 主键自增迁移(已有库执行,可重复执行)
|
|
|
-- 将各表 id 列改为 BIGINT AUTO_INCREMENT,与 MyBatis-Plus IdType.AUTO 对齐
|
|
|
+-- 表不存在时自动跳过,适用于部分表尚未创建的库
|
|
|
|
|
|
-- vpp_customer
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_customer' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_customer') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_customer' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_customer` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_customer.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_customer.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_customer_access
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_customer_access' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_customer_access') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_customer_access' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_customer_access` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_customer_access.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_customer_access.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_customer_contact
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_customer_contact' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_customer_contact') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_customer_contact' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_customer_contact` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_customer_contact.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_customer_contact.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_contract
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_contract' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_contract') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_contract' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_contract` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_contract.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_contract.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_contract_template
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_contract_template' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_contract_template') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_contract_template' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_contract_template` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_contract_template.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_contract_template.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_contract_audit_log
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_contract_audit_log' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_contract_audit_log') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_contract_audit_log' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_contract_audit_log` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_contract_audit_log.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_contract_audit_log.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
@@ -69,177 +76,208 @@ PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_resource_point
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_resource_point' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_resource_point') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_resource_point' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_resource_point` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_resource_point.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_resource_point.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_resource_point_config
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_resource_point_config' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_resource_point_config') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_resource_point_config' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_resource_point_config` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_resource_point_config.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_resource_point_config.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_device
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_device' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_device') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_device' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_device` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_device.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_device.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_device_control_log
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_device_control_log' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_device_control_log') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_device_control_log' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_device_control_log` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_device_control_log.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_device_control_log.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_energy_reading_monthly
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_energy_reading_monthly' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_energy_reading_monthly') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_energy_reading_monthly' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_energy_reading_monthly` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_energy_reading_monthly.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_energy_reading_monthly.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_energy_summary_daily
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_energy_summary_daily' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_energy_summary_daily') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_energy_summary_daily' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_energy_summary_daily` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_energy_summary_daily.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_energy_summary_daily.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_settlement_bill
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_settlement_bill' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_settlement_bill') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_settlement_bill' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_settlement_bill` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_settlement_bill.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_settlement_bill.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_settlement_bill_detail
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_settlement_bill_detail' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_settlement_bill_detail') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_settlement_bill_detail' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_settlement_bill_detail` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_settlement_bill_detail.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_settlement_bill_detail.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_payment_record
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_payment_record' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_payment_record') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_payment_record' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_payment_record` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_payment_record.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_payment_record.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_report_task
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_report_task' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_report_task') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_report_task' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_report_task` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_report_task.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_report_task.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_report_record
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_report_record' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_report_record') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_report_record' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_report_record` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_report_record.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_report_record.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_report_data
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_report_data' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_report_data') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_report_data' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_report_data` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_report_data.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_report_data.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_report_audit_log
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_report_audit_log' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_report_audit_log') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_report_audit_log' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_report_audit_log` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_report_audit_log.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_report_audit_log.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_dr_event
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_event' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_event') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_event' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_dr_event` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_dr_event.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_dr_event.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_dr_participation
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_participation' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_participation') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_participation' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_dr_participation` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_dr_participation.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_dr_participation.id already auto_increment or table missing'''
|
|
|
+);
|
|
|
+PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
+
|
|
|
+-- vpp_dr_invitation
|
|
|
+SET @sql = IF(
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_invitation') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_invitation' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ 'ALTER TABLE `vpp_dr_invitation` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
+ 'SELECT ''skip: vpp_dr_invitation.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_dr_strategy
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_strategy' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_strategy') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_strategy' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_dr_strategy` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_dr_strategy.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_dr_strategy.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_dr_strategy_resource
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_strategy_resource' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_strategy_resource') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_strategy_resource' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_dr_strategy_resource` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_dr_strategy_resource.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_dr_strategy_resource.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_dr_execution
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_execution' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_execution') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_execution' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_dr_execution` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_dr_execution.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_dr_execution.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_dr_evaluation
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_evaluation' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_evaluation') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_dr_evaluation' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_dr_evaluation` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_dr_evaluation.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_dr_evaluation.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_registration
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_registration' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_registration') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_registration' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_registration` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_registration.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_registration.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_report_log
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_report_log' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_report_log') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_report_log' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_report_log` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_report_log.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_report_log.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|
|
|
-- vpp_file_archive
|
|
|
SET @sql = IF(
|
|
|
- (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_file_archive' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
+ (SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'vpp_file_archive') > 0
|
|
|
+ AND (SELECT COUNT(*) FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = 'vpp_file_archive' AND column_name = 'id' AND EXTRA LIKE '%auto_increment%') = 0,
|
|
|
'ALTER TABLE `vpp_file_archive` MODIFY COLUMN `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT ''主键''',
|
|
|
- 'SELECT ''skip: vpp_file_archive.id already auto_increment'''
|
|
|
+ 'SELECT ''skip: vpp_file_archive.id already auto_increment or table missing'''
|
|
|
);
|
|
|
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
|
|
|
|