app/DoctrineMigrations/Version20210319122142.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of EC-CUBE
  5.  *
  6.  * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  7.  *
  8.  * http://www.ec-cube.co.jp/
  9.  *
  10.  * For the full copyright and license information, please view the LICENSE
  11.  * file that was distributed with this source code.
  12.  */
  13. namespace DoctrineMigrations;
  14. use Doctrine\DBAL\Schema\Schema;
  15. use Doctrine\Migrations\AbstractMigration;
  16. use Eccube\Entity\Master\LoginHistoryStatus;
  17. /**
  18.  * Auto-generated Migration: Please modify to your needs!
  19.  */
  20. final class Version20210319122142 extends AbstractMigration
  21. {
  22.     public function up(Schema $schema): void
  23.     {
  24. /*
  25.         $lang = env('ECCUBE_LOCALE');
  26.         $statuses = [
  27.             LoginHistoryStatus::FAILURE => $lang === 'en' ? 'Failure' : '失敗',
  28.             LoginHistoryStatus::SUCCESS => $lang === 'en' ? 'Success' : '成功',
  29.         ];
  30.         $sortNo = $this->connection->fetchOne('SELECT MAX(sort_no) + 1 FROM mtb_login_history_status');
  31.         if (is_null($sortNo)) {
  32.             $sortNo = 0;
  33.         }
  34.         foreach ($statuses as $id => $name) {
  35.             $statusExists = $this->connection->fetchOne(
  36.                 'SELECT COUNT(*) FROM mtb_login_history_status WHERE id = :id',
  37.                 ['id' => $id]
  38.             );
  39.             if ($statusExists == 0) {
  40.                 $this->addSql(
  41.                     "INSERT INTO mtb_login_history_status (id, name, sort_no, discriminator_type) VALUES (?, ?, ?, 'loginhistorystatus')",
  42.                     [$id, $name, $sortNo++]
  43.                 );
  44.             }
  45.         }
  46. */
  47.     }
  48.     public function down(Schema $schema): void
  49.     {
  50.         // this down() migration is auto-generated, please modify it to your needs
  51.     }
  52. }