aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations/Version20161118134328.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/DoctrineMigrations/Version20161118134328.php')
-rw-r--r--app/DoctrineMigrations/Version20161118134328.php18
1 files changed, 12 insertions, 6 deletions
diff --git a/app/DoctrineMigrations/Version20161118134328.php b/app/DoctrineMigrations/Version20161118134328.php
index 390e89ce..f168cb53 100644
--- a/app/DoctrineMigrations/Version20161118134328.php
+++ b/app/DoctrineMigrations/Version20161118134328.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 * Add http_status in `entry_table` 11 * Add http_status in `entry_table`.
12 */ 12 */
13class Version20161118134328 extends AbstractMigration implements ContainerAwareInterface 13class Version20161118134328 extends AbstractMigration implements ContainerAwareInterface
14{ 14{
@@ -24,7 +24,7 @@ class Version20161118134328 extends AbstractMigration implements ContainerAwareI
24 24
25 private function getTable($tableName) 25 private function getTable($tableName)
26 { 26 {
27 return $this->container->getParameter('database_table_prefix') . $tableName; 27 return $this->container->getParameter('database_table_prefix').$tableName;
28 } 28 }
29 29
30 /** 30 /**
@@ -32,7 +32,14 @@ class Version20161118134328 extends AbstractMigration implements ContainerAwareI
32 */ 32 */
33 public function up(Schema $schema) 33 public function up(Schema $schema)
34 { 34 {
35 $this->addSql('ALTER TABLE '.$this->getTable('entry').' ADD http_status VARCHAR(3) DEFAULT NULL'); 35 $entryTable = $schema->getTable($this->getTable('entry'));
36
37 $this->skipIf($entryTable->hasColumn('http_status'), 'It seems that you already played this migration.');
38
39 $entryTable->addColumn('http_status', 'string', [
40 'length' => 3,
41 'notnull' => false,
42 ]);
36 } 43 }
37 44
38 /** 45 /**
@@ -40,8 +47,7 @@ class Version20161118134328 extends AbstractMigration implements ContainerAwareI
40 */ 47 */
41 public function down(Schema $schema) 48 public function down(Schema $schema)
42 { 49 {
43 $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'sqlite', 'This down migration can\'t be executed on SQLite databases, because SQLite don\'t support DROP COLUMN.'); 50 $userTable = $schema->getTable($this->getTable('entry'));
44 51 $userTable->dropColumn('http_status');
45 $this->addSql('ALTER TABLE '.$this->getTable('entry').' DROP http_status');
46 } 52 }
47} 53}