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