ALTER TABLE `method` CHANGE COLUMN `type` `type` VARCHAR(50) NOT NULL DEFAULT '' COLLATE 'utf8_general_ci' AFTER `name`; ALTER TABLE `data_field` CHANGE COLUMN `seq` `seq` VARCHAR(50) NOT NULL AFTER `arraysize`; update data_field set seq = UNIX_TIMESTAMP(CONVERT_TZ(seq, '+00:00', @@session.time_zone)); ALTER TABLE `data_field` CHANGE COLUMN `seq` `seq` int NOT NULL AFTER `arraysize`; set @seqmin = 0; select min(seq) into @seqmin from data_field; update data_field set seq = seq - @seqmin; ALTER TABLE `data_field` CHANGE COLUMN `seq` `seq` INT(11) NOT NULL AUTO_INCREMENT AFTER `arraysize`, ADD INDEX `seq` (`seq`); DROP PROCEDURE IF EXISTS `metadataViewEditMetafieldSeq`; DELIMITER // CREATE PROCEDURE `metadataViewEditMetafieldSeq`(IN `domain_idkey` int, IN `domaintype` varchar(50), IN `metadatakey` varchar(100), IN `metadatakey1` varchar(100), IN `metadatakey2` varchar(100)) BEGIN declare t1 bigint; declare t2 bigint; declare data_auto_id_key int default null; if loginTest() and domainManageTest(domain_idkey) then select 1 as test; select data.data_auto_id into data_auto_id_key from data where data.domain_id=domain_idkey and data.name=metadatakey; select seq into t1 from data_field where data_field.data_auto_id=data_auto_id_key and member_name=metadatakey1; select seq into t2 from data_field where data_field.data_auto_id=data_auto_id_key and member_name=metadatakey2; update data_field set seq = t2 where data_field.data_auto_id=data_auto_id_key and member_name=metadatakey1; update data_field set seq = t1 where data_field.data_auto_id=data_auto_id_key and member_name=metadatakey2; else select 0 as test; end if; END// DELIMITER ;