]> git.immae.eu Git - github/wallabag/wallabag.git/blame - app/DoctrineMigrations/Version20161122203647.php
Add a real configuration for CS-Fixer
[github/wallabag/wallabag.git] / app / DoctrineMigrations / Version20161122203647.php
CommitLineData
be2725db
JB
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
18d7bc3a 11 * Methods and properties removed from `FOS\UserBundle\Model\User`.
be2725db
JB
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 */
21class 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
be2725db
JB
33 /**
34 * @param Schema $schema
35 */
36 public function up(Schema $schema)
37 {
84c6a48d 38 $userTable = $schema->getTable($this->getTable('user'));
be2725db 39
65a8c6e1 40 $this->skipIf(false === $userTable->hasColumn('expired') || false === $userTable->hasColumn('credentials_expired'), 'It seems that you already played this migration.');
18d7bc3a 41
84c6a48d 42 $userTable->dropColumn('expired');
84c6a48d 43 $userTable->dropColumn('credentials_expired');
be2725db
JB
44 }
45
46 /**
47 * @param Schema $schema
48 */
49 public function down(Schema $schema)
50 {
84c6a48d 51 $userTable = $schema->getTable($this->getTable('user'));
4acbeb93
NL
52
53 $this->skipIf(true === $userTable->hasColumn('expired') || true === $userTable->hasColumn('credentials_expired'), 'It seems that you already played this migration.');
54
55 $userTable->addColumn('expired', 'smallint', ['notnull' => false]);
56 $userTable->addColumn('credentials_expired', 'smallint', ['notnull' => false]);
be2725db 57 }
f808b016
JB
58
59 private function getTable($tableName)
60 {
61 return $this->container->getParameter('database_table_prefix') . $tableName;
62 }
be2725db 63}