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') 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