diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-11-28 14:27:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-28 14:27:31 +0100 |
commit | 34ea7be6228c633ef8da703994eed034026e9c18 (patch) | |
tree | e9a3691b1593cb0b3c8d91c0bb93ba586c3fb87f /app/DoctrineMigrations | |
parent | 6bb0866cf513bf939eb2e3290d1852c55e51ec0d (diff) | |
parent | 07326af5e25f52f54f725898d9fb2f82af60e224 (diff) | |
download | wallabag-34ea7be6228c633ef8da703994eed034026e9c18.tar.gz wallabag-34ea7be6228c633ef8da703994eed034026e9c18.tar.zst wallabag-34ea7be6228c633ef8da703994eed034026e9c18.zip |
Merge pull request #2663 from wallabag/remove-fosuser-attributes
Removed FOSUser attributes removed in alpha4
Diffstat (limited to 'app/DoctrineMigrations')
-rw-r--r-- | app/DoctrineMigrations/Version20161128131503.php | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/app/DoctrineMigrations/Version20161128131503.php b/app/DoctrineMigrations/Version20161128131503.php new file mode 100644 index 00000000..f0e016c8 --- /dev/null +++ b/app/DoctrineMigrations/Version20161128131503.php | |||
@@ -0,0 +1,61 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Application\Migrations; | ||
4 | |||
5 | use Doctrine\DBAL\Migrations\AbstractMigration; | ||
6 | use Doctrine\DBAL\Schema\Schema; | ||
7 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
8 | use Symfony\Component\DependencyInjection\ContainerInterface; | ||
9 | |||
10 | /** | ||
11 | * Removed locked, credentials_expire_at and expires_at. | ||
12 | */ | ||
13 | class Version20161128131503 extends AbstractMigration implements ContainerAwareInterface | ||
14 | { | ||
15 | private $fields = [ | ||
16 | 'locked' => 'smallint', | ||
17 | 'credentials_expire_at' => 'datetime', | ||
18 | 'expires_at' => 'datetime', | ||
19 | ]; | ||
20 | |||
21 | /** | ||
22 | * @var ContainerInterface | ||
23 | */ | ||
24 | private $container; | ||
25 | |||
26 | public function setContainer(ContainerInterface $container = null) | ||
27 | { | ||
28 | $this->container = $container; | ||
29 | } | ||
30 | |||
31 | private function getTable($tableName) | ||
32 | { | ||
33 | return $this->container->getParameter('database_table_prefix').$tableName; | ||
34 | } | ||
35 | |||
36 | /** | ||
37 | * @param Schema $schema | ||
38 | */ | ||
39 | public function up(Schema $schema) | ||
40 | { | ||
41 | $userTable = $schema->getTable($this->getTable('user')); | ||
42 | |||
43 | foreach ($this->fields as $field => $type) { | ||
44 | $this->skipIf(!$userTable->hasColumn($field), 'It seems that you already played this migration.'); | ||
45 | $userTable->dropColumn($field); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | /** | ||
50 | * @param Schema $schema | ||
51 | */ | ||
52 | public function down(Schema $schema) | ||
53 | { | ||
54 | $userTable = $schema->getTable($this->getTable('user')); | ||
55 | |||
56 | foreach ($this->fields as $field => $type) { | ||
57 | $this->skipIf($userTable->hasColumn($field), 'It seems that you already played this migration.'); | ||
58 | $userTable->addColumn($field, $type); | ||
59 | } | ||
60 | } | ||
61 | } | ||