Ver Fonte

update sql

oubo há 5 anos atrás
pai
commit
ad2af1f960
2 ficheiros alterados com 27 adições e 19 exclusões
  1. 13 13
      data/sql/structure.sql
  2. 14 6
      data/upgrade/v3.0.0/v3.0.0.sql

+ 13 - 13
data/sql/structure.sql

@@ -179,7 +179,7 @@ CREATE TABLE `t_affair_sheet_column`  (
   `column_order` int(11) NULL DEFAULT 0,
   PRIMARY KEY (`sheet_column_id`) USING BTREE,
   INDEX `sheet_id`(`sheet_id`) USING BTREE,
-  INDEX `system_column_id`(`column_id`) USING BTREE,
+  INDEX `column_id`(`column_id`) USING BTREE,
   CONSTRAINT `t_affair_sheet_column_ibfk_1` FOREIGN KEY (`sheet_id`) REFERENCES `t_affair_sheet` (`sheet_id`) ON DELETE CASCADE ON UPDATE CASCADE,
   CONSTRAINT `t_affair_sheet_column_ibfk_2` FOREIGN KEY (`column_id`) REFERENCES `t_affair_system_column` (`column_id`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE = InnoDB AUTO_INCREMENT = 1 ROW_FORMAT = Dynamic;
@@ -457,7 +457,7 @@ CREATE TABLE `t_company`  (
   `version` int(11) NULL DEFAULT NULL,
   `company_phone`  varchar(255) NULL,
   PRIMARY KEY (`company_id`) USING BTREE,
-  INDEX `FK_Reference_29`(`location_id`) USING BTREE,
+  INDEX `location_id`(`location_id`) USING BTREE,
   INDEX `customerGroupId`(`customerGroupId`) USING BTREE,
   INDEX `company_name`(`company_name`) USING BTREE,
   INDEX `company_shortname`(`company_shortname`) USING BTREE,
@@ -499,7 +499,7 @@ CREATE TABLE `t_customer`  (
   `customer_phone3` varchar(255) NULL DEFAULT '',
   PRIMARY KEY (`id`) USING BTREE,
   INDEX `companyId`(`companyId`) USING BTREE,
-  INDEX `t_customer_ibfk_2`(`customerCompanyId`) USING BTREE,
+  INDEX `customerCompanyId`(`customerCompanyId`) USING BTREE,
   INDEX `id`(`id`, `customerCompanyId`) USING BTREE,
   INDEX `groupId`(`groupId`) USING BTREE,
   CONSTRAINT `t_customer_ibfk_1` FOREIGN KEY (`companyId`) REFERENCES `t_company` (`company_id`) ON DELETE CASCADE ON UPDATE CASCADE,
@@ -561,7 +561,7 @@ CREATE TABLE `t_documentary`  (
   `utime` datetime(0) NULL DEFAULT NULL,
   `status` tinyint(2) NULL DEFAULT 99,
   PRIMARY KEY (`documentary_id`) USING BTREE,
-  UNIQUE INDEX `documentary_number` (`documentary_number_pid`, `documentary_number`) USING BTREE
+  UNIQUE INDEX `documentary_number_pid` (`documentary_number_pid`, `documentary_number`) USING BTREE
 ) ENGINE = InnoDB ROW_FORMAT = Dynamic;
 
 -- ----------------------------
@@ -733,7 +733,7 @@ CREATE TABLE `t_location`  (
   `location_level` tinyint(1) NULL DEFAULT NULL,
   `location_phonenum` varchar(5) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL,
   PRIMARY KEY (`location_id`) USING BTREE,
-  INDEX `FK_Reference_28`(`location_pid`) USING BTREE,
+  INDEX `location_pid`(`location_pid`) USING BTREE,
   CONSTRAINT `FK_Reference_28` FOREIGN KEY (`location_pid`) REFERENCES `t_location` (`location_id`) ON DELETE SET NULL ON UPDATE CASCADE
 ) ENGINE = InnoDB AUTO_INCREMENT = 1 ROW_FORMAT = Dynamic;
 
@@ -992,7 +992,7 @@ CREATE TABLE `t_product`  (
   `product_partially` text CHARACTER SET utf8 NULL,
   PRIMARY KEY (`product_id`) USING BTREE,
   UNIQUE INDEX `product_id`(`product_id`) USING BTREE,
-  INDEX `FK_Relationship_12`(`user_id`) USING BTREE,
+  INDEX `user_id`(`user_id`) USING BTREE,
   INDEX `ctime`(`ctime`) USING BTREE,
   INDEX `status`(`status`) USING BTREE,
   INDEX `company_id`(`company_id`) USING BTREE,
@@ -1044,7 +1044,7 @@ CREATE TABLE `t_r_product_collection`  (
   `product_id` int(11) NOT NULL,
   PRIMARY KEY (`collection_id`, `product_id`) USING BTREE,
   INDEX `product_id`(`product_id`) USING BTREE,
-  INDEX `collection_id_2`(`collection_id`) USING BTREE,
+  INDEX `collection_id`(`collection_id`) USING BTREE,
   CONSTRAINT `t_r_product_collection_ibfk_1` FOREIGN KEY (`collection_id`) REFERENCES `t_collection` (`collection_id`) ON DELETE CASCADE ON UPDATE CASCADE,
   CONSTRAINT `t_r_product_collection_ibfk_2` FOREIGN KEY (`product_id`) REFERENCES `t_product` (`product_id`) ON DELETE CASCADE ON UPDATE CASCADE
 ) ENGINE = InnoDB ROW_FORMAT = Dynamic;
@@ -1318,10 +1318,10 @@ CREATE TABLE `t_statement_calculation`  (
   `calculation_ctime` datetime(0) NULL DEFAULT NULL,
   `calculation_note` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
   PRIMARY KEY (`calculation_id`, `data_id`) USING BTREE,
-  INDEX (`bill_order_number`) USING BTREE,
+  INDEX `bill_order_number`(`bill_order_number`) USING BTREE,
   INDEX `bill_order_id`(`bill_order_id`) USING BTREE,
   INDEX `call_time`(`call_time`) USING BTREE,
-  INDEX ` calculation_value`(`calculation_key`, `affair_id`, `calculation_time`, `calculation_value`, `calculation_condition`, `tagIds`) USING BTREE,
+  INDEX `calculation_value`(`calculation_key`, `affair_id`, `calculation_time`, `calculation_value`, `calculation_condition`, `tagIds`) USING BTREE,
   INDEX `calculation_time`(`calculation_time`, `affair_id`, `calculation_condition`, `tagIds`) USING BTREE
 ) ENGINE = InnoDB AUTO_INCREMENT = 1 ROW_FORMAT = Dynamic;
 
@@ -1365,7 +1365,7 @@ CREATE TABLE `t_tag_list`  (
   `permission_view` INT ( 1 ) NULL DEFAULT 1,
   `tag_group_id`  int(11) NULL DEFAULT 0,
   PRIMARY KEY (`tag_id`) USING BTREE,
-  INDEX `t_tag_list_ibfk_1`(`tag_image_id`) USING BTREE
+  INDEX `tag_image_id`(`tag_image_id`) USING BTREE
 ) ENGINE = InnoDB AUTO_INCREMENT = 1 ROW_FORMAT = Dynamic;
 
 -- ----------------------------
@@ -1456,7 +1456,7 @@ CREATE TABLE `t_user`  (
   `report_password` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NULL,
   `report_password_type` tinyint(1) NULL DEFAULT 0,
   PRIMARY KEY (`user_id`) USING BTREE,
-  INDEX `FK_Relationship_2`(`role_id`) USING BTREE,
+  INDEX `role_id`(`role_id`) USING BTREE,
   INDEX `company_id`(`company_id`) USING BTREE,
   INDEX `department_id`(`department_id`) USING BTREE,
   INDEX `user_name`(`user_name`) USING BTREE,
@@ -1654,7 +1654,7 @@ CREATE TABLE `t_machine_calculation`  (
   `machine_production_state`  tinyint(1) NULL DEFAULT 0,
   PRIMARY KEY (`calculation_id`, `data_id`) USING BTREE,
   INDEX `call_time`(`call_time`) USING BTREE,
-  INDEX ` calculation_value`(`affair_id`, `calculation_key`, `calculation_condition`, `calculation_time`, `product_id`, `tagIds`, `calculation_time2`) USING BTREE
+  INDEX `calculation_value`(`affair_id`, `calculation_key`, `calculation_condition`, `calculation_time`, `product_id`, `tagIds`, `calculation_time2`) USING BTREE
 ) ENGINE = InnoDB ROW_FORMAT = Dynamic;
 -- ----------------------------
 -- Table structure for t_ticket_calculation
@@ -1676,7 +1676,7 @@ CREATE TABLE `t_ticket_calculation`  (
   `ticket_time` datetime(0) NOT NULL ,
   PRIMARY KEY (`calculation_id`, `data_id`) USING BTREE,
   INDEX `call_time`(`call_time`) USING BTREE,
-  INDEX ` calculation_value`(`affair_id`, `calculation_key`, `calculation_condition`, `calculation_time`, `tagIds`, `ticket_key`, `ticket_time`) USING BTREE
+  INDEX `calculation_value`(`affair_id`, `calculation_key`, `calculation_condition`, `calculation_time`, `tagIds`, `ticket_key`, `ticket_time`) USING BTREE
 ) ENGINE = InnoDB ROW_FORMAT = Dynamic;
 -- ----------------------------
 -- Table structure for t_customer_given

+ 14 - 6
data/upgrade/v3.0.0/v3.0.0.sql

@@ -305,7 +305,8 @@ ADD COLUMN IF NOT EXISTS `order_last_time` datetime NULL AFTER `order_first_time
 
 ALTER TABLE `t_bill_order`
 MODIFY COLUMN IF EXISTS `bill_order_number`  varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' AFTER `user_name`,
-ADD UNIQUE INDEX (`bill_order_number`) USING BTREE;
+DROP INDEX IF EXISTS `bill_order_number`,
+ADD UNIQUE INDEX `bill_order_number`(`bill_order_number`) USING BTREE;
 
 ALTER TABLE `t_customized`
 ADD COLUMN IF NOT EXISTS `view_permission`  tinyint(1) NULL DEFAULT 2 AFTER `customized_other`,
@@ -337,8 +338,12 @@ ADD COLUMN IF NOT EXISTS `tag_group_id`  int(11) NULL DEFAULT 0 AFTER `permissio
 
 
 ALTER TABLE `t_documentary` MODIFY COLUMN IF EXISTS`documentary_number_pid`  varchar(50) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '' AFTER `documentary_number`;
-ALTER TABLE `t_documentary` DROP INDEX IF EXISTS `documentary_number` , ADD UNIQUE INDEX `documentary_number` (`documentary_number_pid`, `documentary_number`) USING BTREE;
-ALTER TABLE `t_documentary` ADD INDEX (`documentary_number_pid`, `documentary_state`) ;
+ALTER TABLE `t_documentary` DROP INDEX IF EXISTS `documentary_number` ,
+DROP INDEX IF EXISTS  `documentary_number`,
+ADD UNIQUE INDEX `documentary_number` (`documentary_number_pid`, `documentary_number`) USING BTREE;
+ALTER TABLE `t_documentary`
+DROP INDEX IF EXISTS `documentary_number_pid`,
+ADD INDEX `documentary_number_pid`(`documentary_number_pid`, `documentary_state`);
 ALTER TABLE `t_user_reminder`
 ADD COLUMN IF NOT EXISTS `customer_tag_reminder` tinyint(1) NULL DEFAULT 0 AFTER `documentary_copy_order`;
 
@@ -355,8 +360,10 @@ ADD COLUMN IF NOT EXISTS `share_user_id`  int(11) NULL DEFAULT NULL AFTER `stime
 ALTER TABLE `t_bill_order`
 ADD COLUMN IF NOT EXISTS `order_user_id`  int(11) NULL DEFAULT NULL AFTER `share_user_id`,
 ADD COLUMN IF NOT EXISTS `create_bill_order_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' AFTER `order_user_id`,
-ADD INDEX (`status`, `bill_id`),
-ADD INDEX (`printer_status`, `bill_id`);
+DROP INDEX IF EXISTS `status`,
+ADD INDEX `status`(`status`, `bill_id`),
+DROP INDEX IF EXISTS `printer_status`,
+ADD INDEX `printer_status`(`printer_status`, `bill_id`);
 
 ALTER TABLE `t_bill_permission`
 ADD COLUMN IF NOT EXISTS `allow` tinyint(1) NULL DEFAULT 0 AFTER `user_id`;
@@ -366,7 +373,8 @@ ADD COLUMN IF NOT EXISTS `permission_view` tinyint(1) NULL DEFAULT 1 AFTER `bill
 
 ALTER TABLE `t_product_share`
 MODIFY COLUMN IF EXISTS `share_id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL AFTER `user_id`,
-ADD INDEX (`share_id`),
+DROP INDEX IF EXISTS `share_id`,
+ADD INDEX `share_id`(`share_id`),
 ADD COLUMN IF NOT EXISTS `permission`  int(1) NULL DEFAULT 2 AFTER `hits`,
 ADD COLUMN IF NOT EXISTS `permission_view`  int(1) NULL DEFAULT 2 AFTER `permission`;