From a4d55a9161144f7e0daafff8da13dabc9e090ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 26 Nov 2016 13:34:36 +0100 Subject: Replaced abortIf with skipIf --- app/DoctrineMigrations/Version20161104073720.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'app/DoctrineMigrations/Version20161104073720.php') diff --git a/app/DoctrineMigrations/Version20161104073720.php b/app/DoctrineMigrations/Version20161104073720.php index 16503b4b..7a0361f8 100644 --- a/app/DoctrineMigrations/Version20161104073720.php +++ b/app/DoctrineMigrations/Version20161104073720.php @@ -21,7 +21,7 @@ class Version20161104073720 extends AbstractMigration implements ContainerAwareI private function getTable($tableName) { - return $this->container->getParameter('database_table_prefix') . $tableName; + return $this->container->getParameter('database_table_prefix').$tableName; } /** @@ -48,6 +48,5 @@ class Version20161104073720 extends AbstractMigration implements ContainerAwareI */ public function down(Schema $schema) { - } } -- cgit v1.2.3 From 84c6a48df412af7a15a63de5484c4bbcf27de33e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 26 Nov 2016 15:40:42 +0100 Subject: Added dropColumn for SQLite and some enhancements --- app/DoctrineMigrations/Version20161104073720.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'app/DoctrineMigrations/Version20161104073720.php') diff --git a/app/DoctrineMigrations/Version20161104073720.php b/app/DoctrineMigrations/Version20161104073720.php index 7a0361f8..cd2029cb 100644 --- a/app/DoctrineMigrations/Version20161104073720.php +++ b/app/DoctrineMigrations/Version20161104073720.php @@ -29,18 +29,8 @@ class Version20161104073720 extends AbstractMigration implements ContainerAwareI */ public function up(Schema $schema) { - switch ($this->connection->getDatabasePlatform()->getName()) { - case 'sqlite': - $this->addSql('CREATE INDEX `created_at` ON `'.$this->getTable('entry').'` (`created_at` DESC)'); - break; - - case 'mysql': - $this->addSql('ALTER TABLE '.$this->getTable('entry').' ADD INDEX created_at (created_at);'); - break; - - case 'postgresql': - $this->addSql('CREATE INDEX created_at ON '.$this->getTable('entry').' (created_at DESC)'); - } + $entryTable = $schema->getTable($this->getTable('entry')); + $entryTable->addIndex(['created_at']); } /** -- cgit v1.2.3 From 067ae472cc50a6047d6197f1a042ce239153407d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Wed, 30 Nov 2016 12:29:55 +0100 Subject: Named index --- app/DoctrineMigrations/Version20161104073720.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'app/DoctrineMigrations/Version20161104073720.php') diff --git a/app/DoctrineMigrations/Version20161104073720.php b/app/DoctrineMigrations/Version20161104073720.php index cd2029cb..4721426a 100644 --- a/app/DoctrineMigrations/Version20161104073720.php +++ b/app/DoctrineMigrations/Version20161104073720.php @@ -14,6 +14,8 @@ class Version20161104073720 extends AbstractMigration implements ContainerAwareI */ private $container; + private $indexName = 'IDX_entry_created_at'; + public function setContainer(ContainerInterface $container = null) { $this->container = $container; @@ -30,7 +32,9 @@ class Version20161104073720 extends AbstractMigration implements ContainerAwareI public function up(Schema $schema) { $entryTable = $schema->getTable($this->getTable('entry')); - $entryTable->addIndex(['created_at']); + $this->skipIf($entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.'); + + $entryTable->addIndex(['created_at'], $this->indexName); } /** @@ -38,5 +42,9 @@ class Version20161104073720 extends AbstractMigration implements ContainerAwareI */ public function down(Schema $schema) { + $entryTable = $schema->getTable($this->getTable('entry')); + $this->skipIf(false === $entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.'); + + $entryTable->dropIndex($this->indexName); } } -- cgit v1.2.3