]>
Commit | Line | Data |
---|---|---|
8c3158eb NL |
1 | <?php |
2 | ||
3 | namespace Application\Migrations; | |
4 | ||
8c3158eb | 5 | use Doctrine\DBAL\Schema\Schema; |
bfe7a692 | 6 | use Wallabag\CoreBundle\Doctrine\WallabagMigration; |
8c3158eb NL |
7 | |
8 | /** | |
9 | * Changed length for username, username_canonical, email and email_canonical fields in wallabag_user table. | |
10 | */ | |
bfe7a692 | 11 | class Version20170510082609 extends WallabagMigration |
8c3158eb NL |
12 | { |
13 | private $fields = [ | |
14 | 'username', | |
15 | 'username_canonical', | |
16 | 'email', | |
17 | 'email_canonical', | |
18 | ]; | |
19 | ||
8c3158eb NL |
20 | /** |
21 | * @param Schema $schema | |
22 | */ | |
23 | public function up(Schema $schema) | |
24 | { | |
3ef055ce | 25 | $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL'); |
8c3158eb NL |
26 | |
27 | foreach ($this->fields as $field) { | |
f808b016 | 28 | $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(180) NOT NULL;'); |
8c3158eb NL |
29 | } |
30 | } | |
31 | ||
32 | /** | |
33 | * @param Schema $schema | |
34 | */ | |
35 | public function down(Schema $schema) | |
36 | { | |
3ef055ce | 37 | $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL'); |
8c3158eb NL |
38 | |
39 | foreach ($this->fields as $field) { | |
f808b016 | 40 | $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(255) NOT NULL;'); |
8c3158eb NL |
41 | } |
42 | } | |
43 | } |