3 namespace Application\Migrations
;
5 use Doctrine\DBAL\Schema\Schema
;
6 use Wallabag\CoreBundle\Doctrine\WallabagMigration
;
9 * Added indexes on wallabag_entry.url and wallabag_entry.given_url and wallabag_entry.user_id.
11 class Version20171218135243
extends WallabagMigration
13 private $indexGivenUrl = 'IDX_entry_given_url';
16 * @param Schema $schema
18 public function up(Schema
$schema)
20 $entryTable = $schema->getTable($this->getTable('entry'));
21 $this->skipIf($entryTable->hasIndex($this->indexGivenUrl
), 'It seems that you already played this migration.');
23 switch ($this->connection
->getDatabasePlatform()->getName()) {
25 $sql = 'CREATE UNIQUE INDEX ' . $this->indexGivenUrl
. ' ON ' . $this->getTable('entry') . ' (url, given_url, user_id);';
28 $sql = 'CREATE UNIQUE INDEX ' . $this->indexGivenUrl
. ' ON ' . $this->getTable('entry') . ' (url (255), given_url (255), user_id);';
31 $sql = 'CREATE UNIQUE INDEX ' . $this->indexGivenUrl
. ' ON ' . $this->getTable('entry') . ' (url, given_url, user_id);';
39 * @param Schema $schema
41 public function down(Schema
$schema)
43 $entryTable = $schema->getTable($this->getTable('entry'));
44 $this->skipIf(false === $entryTable->hasIndex($this->indexGivenUrl
), 'It seems that you already played this migration.');
46 $entryTable->dropIndex($this->indexGivenUrl
);