vendor/pimcore/pimcore/bundles/CoreBundle/Migrations/Version20210430124911.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. use Pimcore\Bundle\EcommerceFrameworkBundle\CartManager\CartItem;
  19. /**
  20.  * Auto-generated Migration: Please modify to your needs!
  21.  */
  22. final class Version20210430124911 extends AbstractMigration
  23. {
  24.     public function getDescription(): string
  25.     {
  26.         return 'Changes addedDateTimestamp of Cart Items to mirco seconds';
  27.     }
  28.     public function up(Schema $schema): void
  29.     {
  30.         if ($schema->hasTable(CartItem\Dao::TABLE_NAME)) {
  31.             $this->addSql('ALTER TABLE ecommerceframework_cartitem modify addedDateTimestamp bigint not null;');
  32.             $this->addSql('UPDATE ecommerceframework_cartitem SET addedDateTimestamp = addedDateTimestamp * 1000000;');
  33.         }
  34.     }
  35.     public function down(Schema $schema): void
  36.     {
  37.         if ($schema->hasTable(CartItem\Dao::TABLE_NAME)) {
  38.             $this->addSql('UPDATE ecommerceframework_cartitem SET addedDateTimestamp = FLOOR(addedDateTimestamp / 1000000);');
  39.             $this->addSql('ALTER TABLE ecommerceframework_cartitem modify addedDateTimestamp int(10) not null;');
  40.         }
  41.     }
  42. }