1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
4
|
|
|
|
5
|
|
|
// phpcs:ignoreFile |
6
|
|
|
/** @noinspection PhpIllegalPsrClassPathInspection */ |
7
|
|
|
|
8
|
|
|
namespace DoctrineMigrations; |
9
|
|
|
|
10
|
|
|
use Doctrine\DBAL\DBALException; |
11
|
|
|
use Doctrine\DBAL\Schema\Schema; |
12
|
|
|
use Doctrine\Migrations\AbstractMigration; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Auto-generated Migration: Please modify to your needs! |
16
|
|
|
*/ |
17
|
|
|
final class Version20200229154730 extends AbstractMigration |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @noinspection PhpMissingParentCallCommonInspection |
21
|
|
|
*/ |
22
|
|
|
public function getDescription(): string |
23
|
|
|
{ |
24
|
|
|
return 'User localization support.'; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @noinspection PhpMissingParentCallCommonInspection |
29
|
|
|
*/ |
30
|
|
|
public function isTransactional(): bool |
31
|
|
|
{ |
32
|
|
|
return false; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @throws DBALException |
37
|
|
|
*/ |
38
|
|
|
public function up(Schema $schema): void |
39
|
|
|
{ |
40
|
|
|
// this up() migration is auto-generated, please modify it to your needs |
41
|
|
|
$this->abortIf( |
42
|
|
|
$this->connection->getDatabasePlatform()->getName() !== 'mysql', |
43
|
|
|
'Migration can only be executed safely on \'mysql\'.' |
44
|
|
|
); |
45
|
|
|
|
46
|
|
|
$sql = <<<SQL |
47
|
|
|
ALTER TABLE user |
48
|
|
|
ADD language ENUM('en', 'fi') NOT NULL COMMENT 'User language for translations(DC2Type:EnumLanguage)' AFTER email, |
49
|
|
|
ADD locale ENUM('en', 'fi') NOT NULL COMMENT 'User locale for number, time, date, etc. formatting.(DC2Type:EnumLocale)' AFTER language, |
50
|
|
|
ADD timezone VARCHAR(255) DEFAULT 'Europe/Helsinki' NOT NULL COMMENT 'User timezone which should be used to display time, date, etc.' AFTER locale |
51
|
|
|
SQL; |
52
|
|
|
|
53
|
|
|
$this->addSql($sql); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @noinspection PhpMissingParentCallCommonInspection |
58
|
|
|
* |
59
|
|
|
* @throws DBALException |
60
|
|
|
*/ |
61
|
|
|
public function down(Schema $schema): void |
62
|
|
|
{ |
63
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
64
|
|
|
$this->abortIf( |
65
|
|
|
$this->connection->getDatabasePlatform()->getName() !== 'mysql', |
66
|
|
|
'Migration can only be executed safely on \'mysql\'.' |
67
|
|
|
); |
68
|
|
|
|
69
|
|
|
$this->addSql('ALTER TABLE user DROP language, DROP locale, DROP timezone'); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|