aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations/Version20160812120952.php
diff options
context:
space:
mode:
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}