app/DoctrineMigrations/Version20210412073123.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. use Eccube\Util\StringUtil;
  18. /**
  19.  * Auto-generated Migration: Please modify to your needs!
  20.  */
  21. final class Version20210412073123 extends AbstractMigration
  22. {
  23.     public function up(Schema $schema): void
  24.     {
  25. /*
  26.         if ($schema->hasTable('plg_admin_record_config')) {
  27.             $denyHostsPlugin = $this->connection->fetchOne('select admin_deny_hosts FROM plg_admin_record_config') ?: '';
  28.             $denyHostsPlugin = array_filter(\explode("\n", StringUtil::convertLineFeed($denyHostsPlugin)), function ($str) {
  29.                 return StringUtil::isNotBlank($str);
  30.             });
  31.             $denyHosts = array_merge(env('ECCUBE_ADMIN_DENY_HOSTS', []), $denyHostsPlugin);
  32.             $denyHosts = array_values(array_unique($denyHosts));
  33.             $denyHosts = \json_encode($denyHosts);
  34.             $envFile = __DIR__.'/../../.env';
  35.             $env = file_get_contents($envFile);
  36.             $env = StringUtil::replaceOrAddEnv($env, [
  37.                 'ECCUBE_ADMIN_DENY_HOSTS' => "'${denyHosts}'",
  38.             ]);
  39.             file_put_contents($envFile, $env);
  40.         }
  41.         if ($schema->hasTable('plg_admin_record')) {
  42.             $stmt = $this->connection->createQueryBuilder()
  43.                 ->select('*')
  44.                 ->from('plg_admin_record')
  45.                 ->orderBy('id', 'ASC')
  46.                 ->execute();
  47.             while ($row = $stmt->fetch()) {
  48.                 $this->addSql(
  49.                     "INSERT INTO dtb_login_history (user_name, client_ip, create_date, update_date, login_history_status_id, member_id, discriminator_type) VALUES (?, ?, ?, ?, ?, ?, 'loginhistory')",
  50.                     [
  51.                         $row['user_name'],
  52.                         $row['client_ip'],
  53.                         $row['create_date'],
  54.                         $row['update_date'],
  55.                         $row['success_flg'] ? LoginHistoryStatus::SUCCESS : LoginHistoryStatus::FAILURE,
  56.                         $row['member_id'],
  57.                     ]
  58.                 );
  59.             }
  60.         }
  61. */
  62.     }
  63.     public function down(Schema $schema): void
  64.     {
  65. /*
  66.         if ($schema->hasTable('dtb_login_history')) {
  67.             $this->addSql('DELETE FROM dtb_login_history');
  68.         }
  69. */
  70.     }
  71. }