vendor/pimcore/pimcore/bundles/CoreBundle/Migrations/Version20230428112302.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 Version20230428112302 extends AbstractMigration
  19. {
  20.     public function getDescription(): string
  21.     {
  22.         return 'Migrate notes table schema to have a auto increment column';
  23.     }
  24.     public function up(Schema $schema): void
  25.     {
  26.         $notesData $schema->getTable('notes_data');
  27.         if (!$notesData->hasColumn('auto_id')) {
  28.             $notesData->addColumn('auto_id''integer', [
  29.                 'autoincrement' => true,
  30.             ]);
  31.             $notesData->dropPrimaryKey();
  32.             $notesData->setPrimaryKey(['auto_id']);
  33.             $notesData->addUniqueIndex(['id''name'], 'UNIQ_E5A8E5E2BF3967505E237E06');
  34.         }
  35.     }
  36.     public function down(Schema $schema): void
  37.     {
  38.         $notesData $schema->getTable('notes_data');
  39.         if ($notesData->hasColumn('auto_id')) {
  40.             $notesData->dropPrimaryKey();
  41.             $notesData->dropColumn('auto_id');
  42.             $notesData->setPrimaryKey(['id''name']);
  43.             $notesData->dropIndex('UNIQ_E5A8E5E2BF3967505E237E06');
  44.         }
  45.     }
  46. }