vendor/pimcore/pimcore/bundles/CoreBundle/Migrations/Version20201113143914.php line 1

Open in your IDE?
  1. <?php
  2. /**
  3.  * Pimcore
  4.  *
  5.  * This source file is available under two different licenses:
  6.  * - GNU General Public License version 3 (GPLv3)
  7.  * - Pimcore Commercial License (PCL)
  8.  * Full copyright and license information is available in
  9.  * LICENSE.md which is distributed with this source code.
  10.  *
  11.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  12.  *  @license    http://www.pimcore.org/license     GPLv3 and PCL
  13.  */
  14. namespace Pimcore\Bundle\CoreBundle\Migrations;
  15. use Doctrine\DBAL\Schema\Schema;
  16. use Doctrine\Migrations\AbstractMigration;
  17. /**
  18.  * @internal
  19.  */
  20. final class Version20201113143914 extends AbstractMigration
  21. {
  22.     private $tables = ['documents_email''documents_newsletter''documents_page',
  23.         'documents_snippet''documents_printpage', ];
  24.     /**
  25.      * @param Schema $schema
  26.      */
  27.     public function up(Schema $schema): void
  28.     {
  29.         foreach ($this->tables as $table) {
  30.             if ($schema->getTable($table)->hasColumn('action')) {
  31.                 $this->addSql(sprintf('ALTER TABLE `%s` DROP COLUMN `action`;'$table));
  32.             }
  33.             if ($schema->getTable($table)->hasColumn('module')) {
  34.                 $this->addSql(sprintf('ALTER TABLE `%s` DROP COLUMN `module`;'$table));
  35.             }
  36.         }
  37.     }
  38.     /**
  39.      * @param Schema $schema
  40.      */
  41.     public function down(Schema $schema): void
  42.     {
  43.         $this->write(sprintf('Unable to rollback %s as the data was already deleted.'self::class));
  44.         $this->write(sprintf('Please restore the data from tables %s manually from backup.'implode(','$this->tables)));
  45.     }
  46. }