Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor update scripts to only be executed once, clear rows #18

Merged
merged 1 commit into from
Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
class KwcShop_Kwc_Shop_Cart_Plugins_Voucher_Update_20150309Legacy00001 extends Kwf_Update
{
public function update()
{
$db = Kwf_Registry::get('db');
$executed = $db->fetchOne("SHOW tables LIKE 'kwc_shop_vouchers'");
if ($executed) return;

$db->query(" CREATE TABLE IF NOT EXISTS `kwc_shop_vouchers` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`code` VARCHAR( 20 ) NOT NULL ,
`amount` DECIMAL( 10, 2 ) NOT NULL ,
`date` DATETIME NOT NULL ,
`comment` TEXT NOT NULL
) ENGINE = InnoDB;

ALTER TABLE `kwc_shop_vouchers` ADD UNIQUE (`code`) ;
ALTER TABLE `kwc_shop_vouchers` CHANGE `id` `id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT ;

CREATE TABLE IF NOT EXISTS `kwc_shop_voucher_history` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`voucher_id` INT UNSIGNED NOT NULL ,
`order_id` INT UNSIGNED NULL ,
`amount` DECIMAL( 10, 2 ) NOT NULL ,
INDEX ( `voucher_id` )
) ENGINE = InnoDB ;

ALTER TABLE `kwc_shop_voucher_history` ADD INDEX ( `order_id` ) ;
ALTER TABLE `kwc_shop_voucher_history` ADD `date` DATETIME NOT NULL ,
ADD `comment` TEXT NOT NULL ;
ALTER TABLE `kwc_shop_voucher_history` ADD FOREIGN KEY ( `voucher_id` ) REFERENCES `kwc_shop_vouchers` (
`id`
);

ALTER TABLE `kwc_shop_voucher_history` ADD FOREIGN KEY ( `order_id` ) REFERENCES `kwc_shop_orders` (
`id`
);

ALTER TABLE `kwc_shop_voucher_history` CHANGE `order_id` `order_id` INT( 10 ) UNSIGNED NULL ;
");
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE `kwc_shop_products_trl` (
CREATE TABLE IF NOT EXISTS `kwc_shop_products_trl` (
`component_id` VARCHAR(255) NOT NULL ,
`title` VARCHAR( 200 ) NOT NULL ,
`visible` TINYINT NOT NULL ,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public function update()
$row->size = (int)$row->size_backup;
$row->amount = (int)$row->amount_backup;
$row->save();
Kwf_Model_Abstract::clearAllRows();
}
}
}