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