]>
Commit | Line | Data |
---|---|---|
07326af5 NL |
1 | <?php |
2 | ||
3 | namespace Application\Migrations; | |
4 | ||
07326af5 | 5 | use Doctrine\DBAL\Schema\Schema; |
bfe7a692 | 6 | use Wallabag\CoreBundle\Doctrine\WallabagMigration; |
07326af5 NL |
7 | |
8 | /** | |
9 | * Removed locked, credentials_expire_at and expires_at. | |
10 | */ | |
bfe7a692 | 11 | class Version20161128131503 extends WallabagMigration |
07326af5 NL |
12 | { |
13 | private $fields = [ | |
14 | 'locked' => 'smallint', | |
15 | 'credentials_expire_at' => 'datetime', | |
16 | 'expires_at' => 'datetime', | |
17 | ]; | |
18 | ||
07326af5 NL |
19 | public function up(Schema $schema) |
20 | { | |
21 | $userTable = $schema->getTable($this->getTable('user')); | |
22 | ||
23 | foreach ($this->fields as $field => $type) { | |
24 | $this->skipIf(!$userTable->hasColumn($field), 'It seems that you already played this migration.'); | |
25 | $userTable->dropColumn($field); | |
26 | } | |
27 | } | |
28 | ||
07326af5 NL |
29 | public function down(Schema $schema) |
30 | { | |
31 | $userTable = $schema->getTable($this->getTable('user')); | |
32 | ||
33 | foreach ($this->fields as $field => $type) { | |
34 | $this->skipIf($userTable->hasColumn($field), 'It seems that you already played this migration.'); | |
4acbeb93 | 35 | $userTable->addColumn($field, $type, ['notnull' => false]); |
07326af5 NL |
36 | } |
37 | } | |
38 | } |