]>
Commit | Line | Data |
---|---|---|
b564d350 NL |
1 | <?php |
2 | ||
3 | namespace Application\Migrations; | |
4 | ||
b564d350 | 5 | use Doctrine\DBAL\Schema\Schema; |
bfe7a692 | 6 | use Wallabag\CoreBundle\Doctrine\WallabagMigration; |
b564d350 NL |
7 | |
8 | /** | |
01736b5a | 9 | * Added indexes on wallabag_entry.is_starred and wallabag_entry.is_archived. |
b564d350 | 10 | */ |
bfe7a692 | 11 | class Version20170127093841 extends WallabagMigration |
b564d350 | 12 | { |
b564d350 NL |
13 | private $indexStarredName = 'IDX_entry_starred'; |
14 | private $indexArchivedName = 'IDX_entry_archived'; | |
15 | ||
b564d350 NL |
16 | public function up(Schema $schema) |
17 | { | |
18 | $entryTable = $schema->getTable($this->getTable('entry')); | |
01e76069 | 19 | $this->skipIf($entryTable->hasIndex($this->indexStarredName) && $entryTable->hasIndex($this->indexArchivedName), 'It seems that you already played this migration.'); |
b564d350 NL |
20 | |
21 | $entryTable->addIndex(['is_starred'], $this->indexStarredName); | |
22 | $entryTable->addIndex(['is_archived'], $this->indexArchivedName); | |
23 | } | |
24 | ||
b564d350 NL |
25 | public function down(Schema $schema) |
26 | { | |
27 | $entryTable = $schema->getTable($this->getTable('entry')); | |
01e76069 | 28 | $this->skipIf(false === $entryTable->hasIndex($this->indexStarredName) && false === $entryTable->hasIndex($this->indexArchivedName), 'It seems that you already played this migration.'); |
b564d350 NL |
29 | |
30 | $entryTable->dropIndex($this->indexStarredName); | |
31 | $entryTable->dropIndex($this->indexArchivedName); | |
32 | } | |
33 | } |