-
Notifications
You must be signed in to change notification settings - Fork 30
PES-2788: uninstall may not delete tables #333
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
base: v3.1
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -140,9 +140,13 @@ private function createMultiLangField($translationKey) | |
| private function installDatabase() | ||
| { | ||
| $sql = []; | ||
| // DB migrations do not work with PACKETERY_REMOVE_ALL_DATA set to false | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Co ten komentář znamená? Pokud je nastavena konstanta, tak to přece neovlivní spuštění skriptů ze složky upgrade, ne?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Upgrade soubory se nepoužijí při čerstvé instalaci. Původní řešení to řešilo dropováním tabulek. |
||
| $dropTables = !defined('PACKETERY_REMOVE_ALL_DATA') || PACKETERY_REMOVE_ALL_DATA; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neodpovídá zadání - pokud není konstanta definována, nemají se tabulky odstraňovat. I když v tomto případě by se to tak mohlo řešit.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Měnit dosavadní výchozí chování je blbost. Připravte se na to, že to fungovat nebude. |
||
|
|
||
| $sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'packetery_order`'; | ||
| $sql[] = 'CREATE TABLE `' . _DB_PREFIX_ . 'packetery_order` ( | ||
| if ($dropTables) { | ||
| $sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'packetery_order`'; | ||
| } | ||
| $sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'packetery_order` ( | ||
| `id_order` int, | ||
| `id_cart` int, | ||
| `id_branch` int NULL, | ||
|
|
@@ -173,14 +177,18 @@ private function installDatabase() | |
| UNIQUE(`id_cart`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'; | ||
|
|
||
| $sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'packetery_payment`'; | ||
| $sql[] = 'CREATE TABLE `' . _DB_PREFIX_ . 'packetery_payment` ( | ||
| if ($dropTables) { | ||
| $sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'packetery_payment`'; | ||
| } | ||
| $sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'packetery_payment` ( | ||
| `module_name` varchar(255) NOT NULL PRIMARY KEY, | ||
| `is_cod` tinyint(1) NOT NULL DEFAULT 0 | ||
| ) ENGINE=InnoDB DEFAULT charset=utf8;'; | ||
|
|
||
| $sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'packetery_address_delivery`'; | ||
| $sql[] = 'CREATE TABLE `' . _DB_PREFIX_ . 'packetery_address_delivery` ( | ||
| if ($dropTables) { | ||
| $sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'packetery_address_delivery`'; | ||
| } | ||
| $sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'packetery_address_delivery` ( | ||
| `id_carrier` int NOT NULL PRIMARY KEY, | ||
| `id_branch` varchar(255) NOT NULL, | ||
| `name_branch` varchar(255) NULL, | ||
|
|
@@ -192,19 +200,27 @@ private function installDatabase() | |
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8;'; | ||
|
|
||
| $productAttributeRepository = $this->module->diContainer->get(ProductAttributeRepository::class); | ||
| $sql[] = $productAttributeRepository->getDropTableSql(); | ||
| if ($dropTables) { | ||
| $sql[] = $productAttributeRepository->getDropTableSql(); | ||
| } | ||
| $sql[] = $productAttributeRepository->getCreateTableSql(); | ||
|
|
||
| $apiCarrierRepository = $this->module->diContainer->get(ApiCarrierRepository::class); | ||
| $sql[] = $apiCarrierRepository->getDropTableSql(); | ||
| if ($dropTables) { | ||
| $sql[] = $apiCarrierRepository->getDropTableSql(); | ||
| } | ||
| $sql[] = $apiCarrierRepository->getCreateTableSql(); | ||
|
|
||
| $logRepository = $this->module->diContainer->get(LogRepository::class); | ||
| $sql[] = $logRepository->getDropTableSql(); | ||
| if ($dropTables) { | ||
| $sql[] = $logRepository->getDropTableSql(); | ||
| } | ||
| $sql[] = $logRepository->getCreateTableSql(); | ||
|
|
||
| $packetTrackingRepository = $this->module->diContainer->get(PacketTrackingRepository::class); | ||
| $sql[] = $packetTrackingRepository->getDropTableSql(); | ||
| if ($dropTables) { | ||
| $sql[] = $packetTrackingRepository->getDropTableSql(); | ||
| } | ||
| $sql[] = $packetTrackingRepository->getCreateTableSql(); | ||
|
|
||
| if (!$this->dbTools->executeQueries($sql, $this->getExceptionRaisedText(), true)) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,6 +87,10 @@ public function deleteTab($className) | |
| */ | ||
| private function uninstallDatabase() | ||
| { | ||
| if (defined('PACKETERY_REMOVE_ALL_DATA') && !PACKETERY_REMOVE_ALL_DATA) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neodpovídá zadání - pokud není konstanta definována, nemají se tabulky odstraňovat. |
||
| return true; | ||
| } | ||
Karpec marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| $sql = []; | ||
| // remove tables with payment and carrier settings, and with carriers | ||
| $sql[] = 'DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'packetery_payment`'; | ||
|
|
@@ -140,6 +144,10 @@ private function unregisterHooks() | |
| */ | ||
| private function deleteConfiguration() | ||
| { | ||
| if (defined('PACKETERY_REMOVE_ALL_DATA') && !PACKETERY_REMOVE_ALL_DATA) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neodpovídá zadání - pokud není konstanta definována, nemá se nastavení odstraňovat. |
||
| return true; | ||
| } | ||
|
|
||
| return ( | ||
| Configuration::deleteByName('PACKETERY_APIPASS') && | ||
| Configuration::deleteByName('PACKETERY_ESHOP_ID') && | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.