3 namespace Application\Migrations
;
5 use Doctrine\DBAL\Schema\Schema
;
6 use Wallabag\CoreBundle\Doctrine\WallabagMigration
;
9 * Added indexes on wallabag_entry.is_starred and wallabag_entry.is_archived.
11 class Version20170127093841
extends WallabagMigration
13 private $indexStarredName = 'IDX_entry_starred';
14 private $indexArchivedName = 'IDX_entry_archived';
16 public function up(Schema
$schema)
18 $entryTable = $schema->getTable($this->getTable('entry'));
19 $this->skipIf($entryTable->hasIndex($this->indexStarredName
) && $entryTable->hasIndex($this->indexArchivedName
), 'It seems that you already played this migration.');
21 $entryTable->addIndex(['is_starred'], $this->indexStarredName
);
22 $entryTable->addIndex(['is_archived'], $this->indexArchivedName
);
25 public function down(Schema
$schema)
27 $entryTable = $schema->getTable($this->getTable('entry'));
28 $this->skipIf(false === $entryTable->hasIndex($this->indexStarredName
) && false === $entryTable->hasIndex($this->indexArchivedName
), 'It seems that you already played this migration.');
30 $entryTable->dropIndex($this->indexStarredName
);
31 $entryTable->dropIndex($this->indexArchivedName
);