first commit
This commit is contained in:
79
upgrade/list/upgrade.2012-08-20.php
Normal file
79
upgrade/list/upgrade.2012-08-20.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
class Upgrade14 extends UpgradeNew
|
||||
{
|
||||
// overi, jestli je opravnene provest upgrade
|
||||
public function checkRightfulness_1()
|
||||
{
|
||||
$change = false;
|
||||
|
||||
$SQL = sqlQuery('SHOW FIELDS FROM '.getTableName('order_items'));
|
||||
while ($row = sqlFetchArray($SQL)) {
|
||||
if ($row['Field'] == 'id_product' && $row['Null'] == 'NO') {
|
||||
$change = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $change;
|
||||
}
|
||||
|
||||
// provest samotny upgrade
|
||||
public function makeChanges_1()
|
||||
{
|
||||
$SQL = sqlQuery('ALTER TABLE '.getTableName('order_items').' CHANGE `note` `note` TINYTEXT NULL');
|
||||
$SQL = sqlQuery('ALTER TABLE '.getTableName('cart').' CHANGE `note` `note` TINYTEXT NULL');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
|
||||
// overi, jestli je opravnene provest upgrade
|
||||
public function checkRightfulness_2()
|
||||
{
|
||||
if (!findModule('order_edit')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$change = true;
|
||||
|
||||
$SQL = sqlQuery("SHOW TABLES LIKE '".getTableName('order_edit', false)."'");
|
||||
if (sqlNumRows($SQL) > 0) {
|
||||
$change = false;
|
||||
}
|
||||
|
||||
return $change;
|
||||
}
|
||||
|
||||
// provest samotny upgrade
|
||||
public function makeChanges_2()
|
||||
{
|
||||
// Add order field to support sorting
|
||||
$SQL = sqlQuery("CREATE TABLE IF NOT EXISTS `order_edit` (
|
||||
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`id_item` INT(10) UNSIGNED NOT NULL,
|
||||
`id_order` INT(10) UNSIGNED NOT NULL,
|
||||
`id_product` INT(11) DEFAULT NULL,
|
||||
`id_variation` INT(11) DEFAULT NULL,
|
||||
`pieces` MEDIUMINT(9) NOT NULL DEFAULT '1',
|
||||
`pieces_reserved` MEDIUMINT(9) NOT NULL DEFAULT '0',
|
||||
`piece_price` FLOAT NOT NULL DEFAULT '0',
|
||||
`total_price` FLOAT NOT NULL DEFAULT '0',
|
||||
`descr` TINYTEXT NOT NULL,
|
||||
`tax` FLOAT NOT NULL DEFAULT '0',
|
||||
`date` DATETIME NOT NULL DEFAULT '0000-00-00',
|
||||
`note` TINYTEXT,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `id_invoice` (`id_order`),
|
||||
KEY `id_product` (`id_product`),
|
||||
KEY `id_variation` (`id_variation`)
|
||||
) ENGINE=InnoDB COMMENT='editace objednavky'");
|
||||
|
||||
sqlQuery('ALTER TABLE `order_edit`
|
||||
ADD CONSTRAINT `order_edit_ibfk_1` FOREIGN KEY (`id_order`) REFERENCES `orders` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `order_edit_ibfk_2` FOREIGN KEY (`id_product`) REFERENCES `products` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `order_edit_ibfk_3` FOREIGN KEY (`id_variation`) REFERENCES `products_variations` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `order_edit_ibfk_4` FOREIGN KEY (`id_item`) REFERENCES `order_items` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;');
|
||||
|
||||
$this->upgradeOK();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user