]>
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 | public function up(Schema $schema) | |
21 | { | |
22 | $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL'); | |
23 | ||
24 | foreach ($this->fields as $field) { | |
25 | $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(180) NOT NULL;'); | |
26 | } | |
27 | } | |
28 | ||
29 | public function down(Schema $schema) | |
30 | { | |
31 | $this->skipIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'This migration only apply to MySQL'); | |
32 | ||
33 | foreach ($this->fields as $field) { | |
34 | $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(255) NOT NULL;'); | |
35 | } | |
36 | } | |
37 | } |