<?php
declare(strict_types=1);
namespace Meteor\PromotionGift;
use Shopware\Core\Framework\Plugin;
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
class MeteorPromotionGift extends Plugin
{
public function uninstall(UninstallContext $uninstallContext): void
{
if ($uninstallContext->keepUserData()) {
return;
}
$this->runDestructiveMigrations($uninstallContext);
}
private function runDestructiveMigrations(UninstallContext $uninstallContext): void
{
$connection = $this->container->get(\Doctrine\DBAL\Connection::class);
$connection->executeQuery('SET FOREIGN_KEY_CHECKS=0;');
foreach ($uninstallContext->getMigrationCollection()->getMigrationSteps() as $migration) {
try {
$migration->updateDestructive($connection);
} catch (\Exception $ex) {
// ignore
}
}
$connection->executeQuery('SET FOREIGN_KEY_CHECKS=1;');
}
}