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