aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations/Version20161118134328.php
diff options
context:
space:
mode:
authorJeremy Benoist <j0k3r@users.noreply.github.com>2016-11-30 14:17:40 +0100
committerGitHub <noreply@github.com>2016-11-30 14:17:40 +0100
commit9abac9651fd0af4586245364657dc9455ba5c73c (patch)
treefb8f3e1c5ac43d1f08d4197af7026eb1cd27eb00 /app/DoctrineMigrations/Version20161118134328.php
parentad51d77146494f04466c288b05b57b0d96113fd5 (diff)
parent067ae472cc50a6047d6197f1a042ce239153407d (diff)
downloadwallabag-9abac9651fd0af4586245364657dc9455ba5c73c.tar.gz
wallabag-9abac9651fd0af4586245364657dc9455ba5c73c.tar.zst
wallabag-9abac9651fd0af4586245364657dc9455ba5c73c.zip
Merge pull request #2650 from wallabag/add-hascolumn
Added hasColumn() in migration to check column existence
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}