diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2017-01-27 09:34:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-27 09:34:32 +0100 |
commit | 6fb06904ecde15b1b07d0a2af945338b416cf0e2 (patch) | |
tree | e76f3e8142399316ec5660fab8c646b2c34b8336 /app/DoctrineMigrations/Version20161122203647.php | |
parent | 05fa529bcfde01be5d320cb532900d72cf4b0830 (diff) | |
parent | 78295b99dd1721c613f1ce52e2debbe6f6db7753 (diff) | |
download | wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.tar.gz wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.tar.zst wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.zip |
Merge pull request #2416 from wallabag/2.2
wallabag 2.2.0
Diffstat (limited to 'app/DoctrineMigrations/Version20161122203647.php')
-rw-r--r-- | app/DoctrineMigrations/Version20161122203647.php | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/app/DoctrineMigrations/Version20161122203647.php b/app/DoctrineMigrations/Version20161122203647.php new file mode 100644 index 00000000..9b17d6ef --- /dev/null +++ b/app/DoctrineMigrations/Version20161122203647.php | |||
@@ -0,0 +1,63 @@ | |||
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 | * Methods and properties removed from `FOS\UserBundle\Model\User`. | ||
12 | * | ||
13 | * - `$expired` | ||
14 | * - `$credentialsExpired` | ||
15 | * - `setExpired()` (use `setExpiresAt(\DateTime::now()` instead) | ||
16 | * - `setCredentialsExpired()` (use `setCredentialsExpireAt(\DateTime::now()` instead) | ||
17 | * | ||
18 | * You need to drop the fields `expired` and `credentials_expired` from your database | ||
19 | * schema, because they aren't mapped anymore. | ||
20 | */ | ||
21 | class Version20161122203647 extends AbstractMigration implements ContainerAwareInterface | ||
22 | { | ||
23 | /** | ||
24 | * @var ContainerInterface | ||
25 | */ | ||
26 | private $container; | ||
27 | |||
28 | public function setContainer(ContainerInterface $container = null) | ||
29 | { | ||
30 | $this->container = $container; | ||
31 | } | ||
32 | |||
33 | private function getTable($tableName) | ||
34 | { | ||
35 | return $this->container->getParameter('database_table_prefix').$tableName; | ||
36 | } | ||
37 | |||
38 | /** | ||
39 | * @param Schema $schema | ||
40 | */ | ||
41 | public function up(Schema $schema) | ||
42 | { | ||
43 | $userTable = $schema->getTable($this->getTable('user')); | ||
44 | |||
45 | $this->skipIf(false === $userTable->hasColumn('expired') || false === $userTable->hasColumn('credentials_expired'), 'It seems that you already played this migration.'); | ||
46 | |||
47 | $userTable->dropColumn('expired'); | ||
48 | $userTable->dropColumn('credentials_expired'); | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * @param Schema $schema | ||
53 | */ | ||
54 | public function down(Schema $schema) | ||
55 | { | ||
56 | $userTable = $schema->getTable($this->getTable('user')); | ||
57 | |||
58 | $this->skipIf(true === $userTable->hasColumn('expired') || true === $userTable->hasColumn('credentials_expired'), 'It seems that you already played this migration.'); | ||
59 | |||
60 | $userTable->addColumn('expired', 'smallint', ['notnull' => false]); | ||
61 | $userTable->addColumn('credentials_expired', 'smallint', ['notnull' => false]); | ||
62 | } | ||
63 | } | ||