3 namespace Application\Migrations
;
5 use Doctrine\DBAL\Migrations\AbstractMigration
;
6 use Doctrine\DBAL\Schema\Schema
;
7 use Symfony\Component\DependencyInjection\ContainerAwareInterface
;
8 use Symfony\Component\DependencyInjection\ContainerInterface
;
11 * Methods and properties removed from `FOS\UserBundle\Model\User`.
14 * - `$credentialsExpired`
15 * - `setExpired()` (use `setExpiresAt(\DateTime::now()` instead)
16 * - `setCredentialsExpired()` (use `setCredentialsExpireAt(\DateTime::now()` instead)
18 * You need to drop the fields `expired` and `credentials_expired` from your database
19 * schema, because they aren't mapped anymore.
21 class Version20161122203647
extends AbstractMigration
implements ContainerAwareInterface
24 * @var ContainerInterface
28 public function setContainer(ContainerInterface
$container = null)
30 $this->container
= $container;
33 private function getTable($tableName)
35 return $this->container
->getParameter('database_table_prefix').$tableName;
39 * @param Schema $schema
41 public function up(Schema
$schema)
43 $this->abortIf($this->connection
->getDatabasePlatform()->getName() === 'sqlite', 'This up migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.');
45 $this->skipIf(false === $schema->getTable($this->getTable('user'))->hasColumn('expired'), 'It seems that you already played this migration.');
47 $this->addSql('ALTER TABLE '.$this->getTable('user').' DROP expired');
49 $this->skipIf(false === $schema->getTable($this->getTable('user'))->hasColumn('credentials_expired'), 'It seems that you already played this migration.');
51 $this->addSql('ALTER TABLE '.$this->getTable('user').' DROP credentials_expired');
55 * @param Schema $schema
57 public function down(Schema
$schema)
59 $this->addSql('ALTER TABLE '.$this->getTable('user').' ADD expired tinyint(1) NULL DEFAULT 0');
60 $this->addSql('ALTER TABLE '.$this->getTable('user').' ADD credentials_expired tinyint(1) NULL DEFAULT 0');