vendor/pimcore/pimcore/bundles/CoreBundle/Migrations/Version22020614115124.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 Version22020614115124 extends AbstractMigration
  19. {
  20.     public function getDescription(): string
  21.     {
  22.         return 'Add filesize, width and height to assets_image_thumbnail_cache';
  23.     }
  24.     public function up(Schema $schema): void
  25.     {
  26.         if (!$schema->getTable('assets_image_thumbnail_cache')->hasColumn('filesize')) {
  27.             $this->addSql(
  28.                 'ALTER TABLE `assets_image_thumbnail_cache`
  29.                 ADD COLUMN `filesize` INT UNSIGNED
  30.             ;'
  31.             );
  32.         }
  33.         if (!$schema->getTable('assets_image_thumbnail_cache')->hasColumn('width')) {
  34.             $this->addSql(
  35.                 'ALTER TABLE `assets_image_thumbnail_cache`
  36.                 ADD COLUMN `width` SMALLINT UNSIGNED
  37.             ;'
  38.             );
  39.         }
  40.         if (!$schema->getTable('assets_image_thumbnail_cache')->hasColumn('height')) {
  41.             $this->addSql(
  42.                 'ALTER TABLE `assets_image_thumbnail_cache`
  43.                 ADD COLUMN `height` SMALLINT UNSIGNED
  44.             ;'
  45.             );
  46.         }
  47.     }
  48.     public function down(Schema $schema): void
  49.     {
  50.         if (!$schema->getTable('assets_image_thumbnail_cache')->hasColumn('filesize')) {
  51.             $this->addSql(
  52.                 'ALTER TABLE `assets_image_thumbnail_cache`
  53.                 DROP COLUMN `filesize`
  54.             ;'
  55.             );
  56.         }
  57.         if (!$schema->getTable('assets_image_thumbnail_cache')->hasColumn('width')) {
  58.             $this->addSql(
  59.                 'ALTER TABLE `assets_image_thumbnail_cache`
  60.                 DROP COLUMN `width`
  61.             ;'
  62.             );
  63.         }
  64.         if (!$schema->getTable('assets_image_thumbnail_cache')->hasColumn('height')) {
  65.             $this->addSql(
  66.                 'ALTER TABLE `assets_image_thumbnail_cache`
  67.                 DROP COLUMN `height`
  68.             ;'
  69.             );
  70.         }
  71.     }
  72. }