X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=app%2FDoctrineMigrations%2FVersion20170511211659.php;h=d0752bafec74b48d671c1d1bc5a0ed9fe17c112f;hb=48b0163d247554d7e2f1ec63b717c8216ea9ec59;hp=f2d5cf5e8c3af88fbeb9cfb843953c1bd582a138;hpb=c406cef5b69b0d6c43adef33b5374b209347b637;p=github%2Fwallabag%2Fwallabag.git diff --git a/app/DoctrineMigrations/Version20170511211659.php b/app/DoctrineMigrations/Version20170511211659.php index f2d5cf5e..d0752baf 100644 --- a/app/DoctrineMigrations/Version20170511211659.php +++ b/app/DoctrineMigrations/Version20170511211659.php @@ -2,47 +2,32 @@ namespace Application\Migrations; -use Doctrine\DBAL\Migrations\AbstractMigration; use Doctrine\DBAL\Migrations\SkipMigrationException; use Doctrine\DBAL\Schema\Schema; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Wallabag\CoreBundle\Doctrine\WallabagMigration; /** - * 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 +class Version20170511211659 extends WallabagMigration { - /** - * @var ContainerInterface - */ - private $container; - - public function setContainer(ContainerInterface $container = null) - { - $this->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': + $annotationTableName = $this->getTable('annotation', true); + $userTableName = $this->getTable('user', true); + $entryTableName = $this->getTable('entry', true); + $this->addSql(<<addSql('DROP TABLE ' . $tableName); + $this->addSql('DROP TABLE ' . $annotationTableName); $this->addSql(<<addSql(<<addSql('DROP TABLE __temp__wallabag_annotation'); break; - case 'mysql': - $this->addSql('ALTER TABLE '.$tableName.' MODIFY quote TEXT NOT NULL'); + $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' MODIFY quote TEXT NOT NULL'); break; - case 'postgresql': - $this->addSql('ALTER TABLE '.$tableName.' ALTER COLUMN quote TYPE TEXT'); + $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' ALTER COLUMN quote TYPE TEXT'); break; } } @@ -87,13 +70,11 @@ 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; } }