]> git.immae.eu Git - github/wallabag/wallabag.git/blame_incremental - app/DoctrineMigrations/Version20170127093841.php
Fixed migrations with dash into db name
[github/wallabag/wallabag.git] / app / DoctrineMigrations / Version20170127093841.php
... / ...
CommitLineData
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Schema\Schema;
6use Wallabag\CoreBundle\Doctrine\WallabagMigration;
7
8/**
9 * Added indexes on wallabag_entry.is_starred and wallabag_entry.is_archived.
10 */
11class Version20170127093841 extends WallabagMigration
12{
13 private $indexStarredName = 'IDX_entry_starred';
14 private $indexArchivedName = 'IDX_entry_archived';
15
16 /**
17 * @param Schema $schema
18 */
19 public function up(Schema $schema)
20 {
21 $entryTable = $schema->getTable($this->getTable('entry'));
22 $this->skipIf($entryTable->hasIndex($this->indexStarredName) && $entryTable->hasIndex($this->indexArchivedName), 'It seems that you already played this migration.');
23
24 $entryTable->addIndex(['is_starred'], $this->indexStarredName);
25 $entryTable->addIndex(['is_archived'], $this->indexArchivedName);
26 }
27
28 /**
29 * @param Schema $schema
30 */
31 public function down(Schema $schema)
32 {
33 $entryTable = $schema->getTable($this->getTable('entry'));
34 $this->skipIf(false === $entryTable->hasIndex($this->indexStarredName) && false === $entryTable->hasIndex($this->indexArchivedName), 'It seems that you already played this migration.');
35
36 $entryTable->dropIndex($this->indexStarredName);
37 $entryTable->dropIndex($this->indexArchivedName);
38 }
39}