aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations/Version20160916201049.php
diff options
context:
space:
mode:
authorJeremy Benoist <j0k3r@users.noreply.github.com>2017-01-27 09:34:32 +0100
committerGitHub <noreply@github.com>2017-01-27 09:34:32 +0100
commit6fb06904ecde15b1b07d0a2af945338b416cf0e2 (patch)
treee76f3e8142399316ec5660fab8c646b2c34b8336 /app/DoctrineMigrations/Version20160916201049.php
parent05fa529bcfde01be5d320cb532900d72cf4b0830 (diff)
parent78295b99dd1721c613f1ce52e2debbe6f6db7753 (diff)
downloadwallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.tar.gz
wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.tar.zst
wallabag-6fb06904ecde15b1b07d0a2af945338b416cf0e2.zip
Merge pull request #2416 from wallabag/2.2
wallabag 2.2.0
Diffstat (limited to 'app/DoctrineMigrations/Version20160916201049.php')
-rw-r--r--app/DoctrineMigrations/Version20160916201049.php20
1 files changed, 13 insertions, 7 deletions
diff --git a/app/DoctrineMigrations/Version20160916201049.php b/app/DoctrineMigrations/Version20160916201049.php
index 0d2edf9e..9f8e77e7 100644
--- a/app/DoctrineMigrations/Version20160916201049.php
+++ b/app/DoctrineMigrations/Version20160916201049.php
@@ -7,6 +7,9 @@ use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface; 7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface; 8use Symfony\Component\DependencyInjection\ContainerInterface;
9 9
10/**
11 * Added pocket_consumer_key field on wallabag_config
12 */
10class Version20160916201049 extends AbstractMigration implements ContainerAwareInterface 13class Version20160916201049 extends AbstractMigration implements ContainerAwareInterface
11{ 14{
12 /** 15 /**
@@ -21,7 +24,7 @@ class Version20160916201049 extends AbstractMigration implements ContainerAwareI
21 24
22 private function getTable($tableName) 25 private function getTable($tableName)
23 { 26 {
24 return $this->container->getParameter('database_table_prefix') . $tableName; 27 return $this->container->getParameter('database_table_prefix').$tableName;
25 } 28 }
26 29
27 /** 30 /**
@@ -29,8 +32,12 @@ class Version20160916201049 extends AbstractMigration implements ContainerAwareI
29 */ 32 */
30 public function up(Schema $schema) 33 public function up(Schema $schema)
31 { 34 {
32 $this->addSql('ALTER TABLE "'.$this->getTable('config').'" ADD pocket_consumer_key VARCHAR(255) DEFAULT NULL'); 35 $configTable = $schema->getTable($this->getTable('config'));
33 $this->addSql("DELETE FROM \"".$this->getTable('craue_config_setting')."\" WHERE name = 'pocket_consumer_key';"); 36
37 $this->skipIf($configTable->hasColumn('pocket_consumer_key'), 'It seems that you already played this migration.');
38
39 $configTable->addColumn('pocket_consumer_key', 'string', ['notnull' => false]);
40 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'pocket_consumer_key';");
34 } 41 }
35 42
36 /** 43 /**
@@ -38,9 +45,8 @@ class Version20160916201049 extends AbstractMigration implements ContainerAwareI
38 */ 45 */
39 public function down(Schema $schema) 46 public function down(Schema $schema)
40 { 47 {
41 $this->abortIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); 48 $configTable = $schema->getTable($this->getTable('config'));
42 49 $configTable->dropColumn('pocket_consumer_key');
43 $this->addSql('ALTER TABLE "'.$this->getTable('config').'" DROP pocket_consumer_key'); 50 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('pocket_consumer_key', NULL, 'import')");
44 $this->addSql("INSERT INTO \"".$this->getTable('craue_config_setting')."\" (name, value, section) VALUES ('pocket_consumer_key', NULL, 'import')");
45 } 51 }
46} 52}