From 2c3e148b0029a094431622feac79fafcd0d43fc8 Mon Sep 17 00:00:00 2001 From: adev Date: Sun, 7 May 2017 17:21:30 +0200 Subject: Displays an error with an annotation with a too long quote Fix #2762 --- app/DoctrineMigrations/Version20170511211659.php | 100 +++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 app/DoctrineMigrations/Version20170511211659.php (limited to 'app/DoctrineMigrations/Version20170511211659.php') diff --git a/app/DoctrineMigrations/Version20170511211659.php b/app/DoctrineMigrations/Version20170511211659.php new file mode 100644 index 00000000..d19b5ac5 --- /dev/null +++ b/app/DoctrineMigrations/Version20170511211659.php @@ -0,0 +1,100 @@ +container = $container; + } + + private function getTable($tableName) + { + return $this->container->getParameter('database_table_prefix') . $tableName; + } + + public function up(Schema $schema) + { + $tableName = $this->getTable('annotation'); + + switch ($this->connection->getDatabasePlatform()->getName()) { + case 'sqlite': + $this->addSql(<<addSql('DROP TABLE ' . $tableName); + $this->addSql(<<addSql(<<addSql('DROP TABLE __temp__wallabag_annotation'); + break; + + case 'mysql': + $this->addSql('ALTER TABLE '.$tableName.' MODIFY quote TEXT NOT NULL'); + break; + + case 'postgresql': + $this->addSql('ALTER TABLE '.$tableName.' ALTER COLUMN quote TYPE TEXT NOT NULL '); + break; + } + } + + public function down(Schema $schema) + { + $tableName = $this->getTable('annotation'); + + switch ($this->connection->getDatabasePlatform()->getName()) { + case 'sqlite': + throw new SkipMigrationException('Too complex ...'); + break; + + case 'mysql': + $this->addSql('ALTER TABLE '.$tableName.' MODIFY quote VARCHAR(255) NOT NULL'); + break; + + case 'postgresql': + $this->addSql('ALTER TABLE '.$tableName.' ALTER COLUMN quote TYPE VARCHAR(255) NOT NULL '); + break; + } + } +} -- cgit v1.2.3 From c406cef5b69b0d6c43adef33b5374b209347b637 Mon Sep 17 00:00:00 2001 From: adev Date: Wed, 7 Jun 2017 00:12:20 +0200 Subject: Fix postgresql migration --- app/DoctrineMigrations/Version20170511211659.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/DoctrineMigrations/Version20170511211659.php') diff --git a/app/DoctrineMigrations/Version20170511211659.php b/app/DoctrineMigrations/Version20170511211659.php index d19b5ac5..f2d5cf5e 100644 --- a/app/DoctrineMigrations/Version20170511211659.php +++ b/app/DoctrineMigrations/Version20170511211659.php @@ -74,7 +74,7 @@ EOD break; case 'postgresql': - $this->addSql('ALTER TABLE '.$tableName.' ALTER COLUMN quote TYPE TEXT NOT NULL '); + $this->addSql('ALTER TABLE '.$tableName.' ALTER COLUMN quote TYPE TEXT'); break; } } @@ -93,7 +93,7 @@ EOD break; case 'postgresql': - $this->addSql('ALTER TABLE '.$tableName.' ALTER COLUMN quote TYPE VARCHAR(255) NOT NULL '); + $this->addSql('ALTER TABLE '.$tableName.' ALTER COLUMN quote TYPE VARCHAR(255)'); break; } } -- cgit v1.2.3 From f808b01692a835673f328d7221ba8c212caa9b61 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Sat, 1 Jul 2017 09:52:38 +0200 Subject: Add a real configuration for CS-Fixer --- app/DoctrineMigrations/Version20170511211659.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'app/DoctrineMigrations/Version20170511211659.php') diff --git a/app/DoctrineMigrations/Version20170511211659.php b/app/DoctrineMigrations/Version20170511211659.php index f2d5cf5e..f004d1b3 100644 --- a/app/DoctrineMigrations/Version20170511211659.php +++ b/app/DoctrineMigrations/Version20170511211659.php @@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Increase the length of the "quote" column of "annotation" table + * Increase the length of the "quote" column of "annotation" table. */ class Version20170511211659 extends AbstractMigration implements ContainerAwareInterface { @@ -23,11 +23,6 @@ class Version20170511211659 extends AbstractMigration implements ContainerAwareI $this->container = $container; } - private function getTable($tableName) - { - return $this->container->getParameter('database_table_prefix') . $tableName; - } - public function up(Schema $schema) { $tableName = $this->getTable('annotation'); @@ -68,13 +63,11 @@ EOD ); $this->addSql('DROP TABLE __temp__wallabag_annotation'); break; - case 'mysql': - $this->addSql('ALTER TABLE '.$tableName.' MODIFY quote TEXT NOT NULL'); + $this->addSql('ALTER TABLE ' . $tableName . ' MODIFY quote TEXT NOT NULL'); break; - case 'postgresql': - $this->addSql('ALTER TABLE '.$tableName.' ALTER COLUMN quote TYPE TEXT'); + $this->addSql('ALTER TABLE ' . $tableName . ' ALTER COLUMN quote TYPE TEXT'); break; } } @@ -87,14 +80,17 @@ EOD case 'sqlite': throw new SkipMigrationException('Too complex ...'); break; - case 'mysql': - $this->addSql('ALTER TABLE '.$tableName.' MODIFY quote VARCHAR(255) NOT NULL'); + $this->addSql('ALTER TABLE ' . $tableName . ' MODIFY quote VARCHAR(255) NOT NULL'); break; - case 'postgresql': - $this->addSql('ALTER TABLE '.$tableName.' ALTER COLUMN quote TYPE VARCHAR(255)'); + $this->addSql('ALTER TABLE ' . $tableName . ' ALTER COLUMN quote TYPE VARCHAR(255)'); break; } } + + private function getTable($tableName) + { + return $this->container->getParameter('database_table_prefix') . $tableName; + } } -- cgit v1.2.3