aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations/Version20161122203647.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/DoctrineMigrations/Version20161122203647.php')
-rw-r--r--app/DoctrineMigrations/Version20161122203647.php17
1 files changed, 10 insertions, 7 deletions
diff --git a/app/DoctrineMigrations/Version20161122203647.php b/app/DoctrineMigrations/Version20161122203647.php
index ea2703b6..94197193 100644
--- a/app/DoctrineMigrations/Version20161122203647.php
+++ b/app/DoctrineMigrations/Version20161122203647.php
@@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface; 8use Symfony\Component\DependencyInjection\ContainerInterface;
9 9
10/** 10/**
11 * Methods and properties removed from `FOS\UserBundle\Model\User` 11 * Methods and properties removed from `FOS\UserBundle\Model\User`.
12 * 12 *
13 * - `$expired` 13 * - `$expired`
14 * - `$credentialsExpired` 14 * - `$credentialsExpired`
@@ -32,7 +32,7 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI
32 32
33 private function getTable($tableName) 33 private function getTable($tableName)
34 { 34 {
35 return $this->container->getParameter('database_table_prefix') . $tableName; 35 return $this->container->getParameter('database_table_prefix').$tableName;
36 } 36 }
37 37
38 /** 38 /**
@@ -40,10 +40,12 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI
40 */ 40 */
41 public function up(Schema $schema) 41 public function up(Schema $schema)
42 { 42 {
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.'); 43 $userTable = $schema->getTable($this->getTable('user'));
44 44
45 $this->addSql('ALTER TABLE '.$this->getTable('user').' DROP expired'); 45 $this->skipIf(false === $userTable->hasColumn('expired') || false === $userTable->hasColumn('credentials_expired'), 'It seems that you already played this migration.');
46 $this->addSql('ALTER TABLE '.$this->getTable('user').' DROP credentials_expired'); 46
47 $userTable->dropColumn('expired');
48 $userTable->dropColumn('credentials_expired');
47 } 49 }
48 50
49 /** 51 /**
@@ -51,7 +53,8 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI
51 */ 53 */
52 public function down(Schema $schema) 54 public function down(Schema $schema)
53 { 55 {
54 $this->addSql('ALTER TABLE '.$this->getTable('user').' ADD expired tinyint(1) NULL DEFAULT 0'); 56 $userTable = $schema->getTable($this->getTable('user'));
55 $this->addSql('ALTER TABLE '.$this->getTable('user').' ADD credentials_expired tinyint(1) NULL DEFAULT 0'); 57 $userTable->addColumn('expired', 'smallint');
58 $userTable->addColumn('credentials_expired', 'smallint');
56 } 59 }
57} 60}