aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations/Version20160812120952.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/Version20160812120952.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/Version20160812120952.php')
-rw-r--r--app/DoctrineMigrations/Version20160812120952.php24
1 files changed, 10 insertions, 14 deletions
diff --git a/app/DoctrineMigrations/Version20160812120952.php b/app/DoctrineMigrations/Version20160812120952.php
index 3aafea64..bd6e8d63 100644
--- a/app/DoctrineMigrations/Version20160812120952.php
+++ b/app/DoctrineMigrations/Version20160812120952.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 name field on wallabag_oauth2_clients
12 */
10class Version20160812120952 extends AbstractMigration implements ContainerAwareInterface 13class Version20160812120952 extends AbstractMigration implements ContainerAwareInterface
11{ 14{
12 /** 15 /**
@@ -21,7 +24,7 @@ class Version20160812120952 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,16 +32,10 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI
29 */ 32 */
30 public function up(Schema $schema) 33 public function up(Schema $schema)
31 { 34 {
32 switch ($this->connection->getDatabasePlatform()->getName()) { 35 $clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
33 case 'sqlite': 36 $this->skipIf($clientsTable->hasColumn('name'), 'It seems that you already played this migration.');
34 $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name longtext DEFAULT NULL'); 37
35 break; 38 $clientsTable->addColumn('name', 'blob');
36 case 'mysql':
37 $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name longtext COLLATE \'utf8_unicode_ci\' DEFAULT NULL');
38 break;
39 case 'postgresql':
40 $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' ADD name text DEFAULT NULL');
41 }
42 } 39 }
43 40
44 /** 41 /**
@@ -46,8 +43,7 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI
46 */ 43 */
47 public function down(Schema $schema) 44 public function down(Schema $schema)
48 { 45 {
49 $this->abortIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); 46 $clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
50 47 $clientsTable->dropColumn('name');
51 $this->addSql('ALTER TABLE '.$this->getTable('oauth2_clients').' DROP COLUMN name');
52 } 48 }
53} 49}