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

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * Pimcore
  5.  *
  6.  * This source file is available under two different licenses:
  7.  * - GNU General Public License version 3 (GPLv3)
  8.  * - Pimcore Commercial License (PCL)
  9.  * Full copyright and license information is available in
  10.  * LICENSE.md which is distributed with this source code.
  11.  *
  12.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  13.  *  @license    http://www.pimcore.org/license     GPLv3 and PCL
  14.  */
  15. namespace Pimcore\Bundle\CoreBundle\Migrations;
  16. use Doctrine\DBAL\Schema\Schema;
  17. use Doctrine\Migrations\AbstractMigration;
  18. final class Version20230322114936 extends AbstractMigration
  19. {
  20.     private const CONTENT_MASTER_DOC_ID 'contentMasterDocumentId';
  21.     private const CONTENT_MAIN_DOC_ID 'contentMainDocumentId';
  22.     private const TABLES = ['documents_page''documents_snippet''documents_printpage'];
  23.     public function getDescription(): string
  24.     {
  25.         return 'rename master to main';
  26.     }
  27.     public function up(Schema $schema): void
  28.     {
  29.         $this->addSql('ALTER TABLE email_blacklist RENAME email_blocklist;');
  30.         foreach (self::TABLES as $tableName) {
  31.             if ($schema->getTable($tableName)->hasColumn(self::CONTENT_MASTER_DOC_ID)) {
  32.                 $this->addSql(sprintf('ALTER TABLE %s CHANGE COLUMN %s %s int(11) DEFAULT NULL NULL;'$tableNameself::CONTENT_MASTER_DOC_IDself::CONTENT_MAIN_DOC_ID));
  33.             }
  34.         }
  35.     }
  36.     public function down(Schema $schema): void
  37.     {
  38.         $this->addSql('ALTER TABLE email_blocklist RENAME email_blacklist;');
  39.         foreach (self::TABLES as $tableName) {
  40.             if ($schema->getTable($tableName)->hasColumn(self::CONTENT_MAIN_DOC_ID)) {
  41.                 $this->addSql(sprintf('ALTER TABLE %s CHANGE COLUMN %s %s int(11) DEFAULT NULL NULL;'$tableNameself::CONTENT_MAIN_DOC_IDself::CONTENT_MASTER_DOC_ID));
  42.             }
  43.         }
  44.     }
  45. }