Changeset 742 for trunk/Common/Setup/Updates.php
- Timestamp:
- Jul 7, 2015, 12:12:12 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Common/Setup/Updates.php
r741 r742 1435 1435 $Manager->Execute('UPDATE `FinanceInvoice` SET `Direction` = 1 WHERE ValueSign=1'); 1436 1436 } 1437 1438 function UpdateTo742($Manager) 1439 { 1440 $Manager->Execute('CREATE TABLE IF NOT EXISTS `DocumentLineCode` ( 1441 `Id` int(11) NOT NULL AUTO_INCREMENT, 1442 `DocumentLine` int(11) NULL, 1443 `Name` varchar(255) NOT NULL, 1444 PRIMARY KEY (`Id`), 1445 UNIQUE KEY `Name` (`Name`), 1446 KEY `DocumentLine` (`DocumentLine`) 1447 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'); 1448 $Manager->Execute('ALTER TABLE `DocumentLineCode` 1449 ADD CONSTRAINT `DocumentLineCode_ibfk_1` FOREIGN KEY (`DocumentLine`) REFERENCES `DocumentLine` (`Id`);'); 1450 1451 // Transform finance operations 1452 $Manager->Execute('ALTER TABLE `FinanceOperation` CHANGE `BillCode` `BillCodeText` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL'); 1453 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD `BillCode` INT NULL AFTER `BillCodeText`, ADD INDEX (`BillCode`)'); 1454 $Manager->Execute('ALTER TABLE `FinanceOperation` ADD FOREIGN KEY (`BillCode`) REFERENCES `DocumentLineCode`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); 1455 $DbResult = $Manager->Execute('SELECT `FinanceOperation`.`Id`, `FinanceOperation`.`BillCodeText`, `FinanceOperationGroup`.`DocumentLine` '. 1456 'FROM `FinanceInvoice` '. 1457 'LEFT JOIN `FinanceOperationGroup` ON `FinanceOperationGroup`.`Id` = `FinanceOperation`.`Group` '. 1458 'WHERE `FinanceOperation`.`BillCodeText`!=""'); 1459 while($DbRow = $DbResult->fetch_assoc()) 1460 { 1461 if($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL'; 1462 $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '. 1463 'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");'); 1464 $CodeId = $Manager->Database->insert_id; 1465 $Manager->Execute('UPDATE `FinanceOperation` SET `BillCode`='.$CodeId.' WHERE `Id`='.$DbRow['Id']); 1466 } 1467 $Manager->Execute('ALTER TABLE `FinanceOperation` DROP `BillCodeText`;'); 1468 1469 // Transform invoices 1470 $Manager->Execute('ALTER TABLE `FinanceInvoice` CHANGE `BillCode` `BillCodeText` VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL'); 1471 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD `BillCode` INT NULL AFTER `BillCodeText`, ADD INDEX (`BillCode`)'); 1472 $Manager->Execute('ALTER TABLE `FinanceInvoice` ADD FOREIGN KEY (`BillCode`) REFERENCES `DocumentLineCode`(`Id`) ON DELETE RESTRICT ON UPDATE RESTRICT;'); 1473 $DbResult = $Manager->Execute('SELECT `FinanceInvoice`.`Id`, `FinanceInvoice`.`BillCodeText`, `FinanceInvoiceGroup`.`DocumentLine` '. 1474 'FROM `FinanceInvoice` '. 1475 'LEFT JOIN `FinanceInvoiceGroup` ON `FinanceInvoiceGroup`.`Id` = `FinanceInvoice`.`Group` '. 1476 'WHERE `FinanceInvoice`.`BillCodeText`!=""'); 1477 while($DbRow = $DbResult->fetch_assoc()) 1478 { 1479 if($DbRow['DocumentLine'] == '') $DbRow['DocumentLine'] = 'NULL'; 1480 $Manager->Execute('INSERT INTO `DocumentLineCode` (`Id` ,`DocumentLine` ,`Name`) '. 1481 'VALUES (NULL , '.$DbRow['DocumentLine'].', "'.$DbRow['BillCodeText'].'");'); 1482 $CodeId = $Manager->Database->insert_id; 1483 $Manager->Execute('UPDATE `FinanceInvoice` SET `BillCode`='.$CodeId.' WHERE `Id`='.$DbRow['Id']); 1484 } 1485 $Manager->Execute('ALTER TABLE `FinanceInvoice` DROP `BillCodeText`;'); 1486 1487 //$Manager->Execute('RENAME TABLE `FinanceOperationGroup` TO `FinanceOperationTemplate`'); 1488 //$Manager->Execute('RENAME TABLE `FinanceInvoiceGroup` TO `FinanceInvoiceTemplate`'); 1489 } 1490 1437 1491 1438 1492 class Updates … … 1503 1557 735 => array('Revision' => 736, 'Function' => 'UpdateTo736'), 1504 1558 736 => array('Revision' => 739, 'Function' => 'UpdateTo739'), 1505 739 => array('Revision' => 740, 'Function' => 'UpdateTo740'), 1506 740 => array('Revision' => 741, 'Function' => 'UpdateTo741'), 1559 739 => array('Revision' => 740, 'Function' => 'UpdateTo740'), 1560 740 => array('Revision' => 741, 'Function' => 'UpdateTo741'), 1561 741 => array('Revision' => 742, 'Function' => 'UpdateTo742'), 1507 1562 )); 1508 1563 }
Note:
See TracChangeset
for help on using the changeset viewer.