Skip to content

Commit

Permalink
Corrección para desinstalación. (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
barbanet authored Jun 17, 2020
1 parent 9f4edd7 commit ec82a2d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions Setup/Patch/Data/AddRegions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@

use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;

class AddRegions implements DataPatchInterface
class AddRegions implements DataPatchInterface, PatchRevertableInterface
{
/**
* ModuleDataSetupInterface
Expand Down Expand Up @@ -93,21 +94,27 @@ public function apply()
}

/**
* Revert patches
* @see https://devdocs.magento.com/guides/v2.3/extension-dev-guide/declarative-schema/data-patches.html#revertingDataPatches
* Revert patch
*/
public function revert()
{
$this->moduleDataSetup->getConnection()->startSetup();

$tableDirectoryCountryRegionName = $this->moduleDataSetup->getTable('directory_country_region_name');
$tableDirectoryCountryRegion = $this->moduleDataSetup->getTable('directory_country_region');

$where = [
'region_id IN (SELECT region_id FROM ' . $tableDirectoryCountryRegion . ' WHERE country_id = ?)' => 'AR'
];
$this->moduleDataSetup->getConnection()->delete(
$this->moduleDataSetup->getTable('directory_country_region_name'),
['region_id IN (SELECT region_id FROM directory_country_region WHERE country_id = ?)' => 'AR']
$tableDirectoryCountryRegionName,
$where
);

$where = ['country_id = ?' => 'AR'];
$this->moduleDataSetup->getConnection()->delete(
$this->moduleDataSetup->getTable('directory_country_region'),
['country_id = ?' => 'AR']
$tableDirectoryCountryRegion,
$where
);

$this->moduleDataSetup->getConnection()->endSetup();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"magento/module-directory": "100.*"
},
"type": "magento2-module",
"version": "2.0.0",
"version": "2.0.1",
"license": [
"MIT"
],
Expand Down

0 comments on commit ec82a2d

Please sign in to comment.