Add user_archived index

Signed-off-by: Olivier Mehani <shtrom@ssji.net>
This commit is contained in:
Olivier Mehani 2019-08-07 21:44:00 +10:00
parent b700b38e17
commit 588de419e0
No known key found for this signature in database
GPG key ID: 6F82C3C767D655AA
2 changed files with 7 additions and 0 deletions

View file

@ -32,16 +32,19 @@ final class Version20190806130304 extends WallabagMigration
$this->addSql('CREATE INDEX IDX_F4D18282A76ED395 ON ' . $this->getTable('entry', true) . ' (user_id)');
$this->addSql('CREATE INDEX hashed_given_url_user_id ON ' . $this->getTable('entry', true) . ' (user_id, hashed_given_url)');
$this->addSql('CREATE INDEX user_language ON ' . $this->getTable('entry', true) . ' (language, user_id)');
$this->addSql('CREATE INDEX user_archived ON ' . $this->getTable('entry', true) . ' (user_id, is_archived, archived_at)');
$this->addSql('CREATE INDEX user_starred ON ' . $this->getTable('entry', true) . ' (user_id, is_starred, starred_at)');
break;
case 'mysql':
$this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' MODIFY language VARCHAR(20) DEFAULT NULL');
$this->addSql('CREATE INDEX user_language ON ' . $this->getTable('entry') . ' (language, user_id)');
$this->addSql('CREATE INDEX user_archived ON ' . $this->getTable('entry') . ' (user_id, is_archived, archived_at)');
$this->addSql('CREATE INDEX user_starred ON ' . $this->getTable('entry') . ' (user_id, is_starred, starred_at)');
break;
case 'postgresql':
$this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' ALTER language TYPE VARCHAR(20)');
$this->addSql('CREATE INDEX user_language ON ' . $this->getTable('entry') . ' (language, user_id)');
$this->addSql('CREATE INDEX user_archived ON ' . $this->getTable('entry') . ' (user_id, is_archived, archived_at)');
$this->addSql('CREATE INDEX user_starred ON ' . $this->getTable('entry') . ' (user_id, is_starred, starred_at)');
break;
}
@ -57,6 +60,7 @@ final class Version20190806130304 extends WallabagMigration
$this->addSql('DROP INDEX hashed_url_user_id');
$this->addSql('DROP INDEX hashed_given_url_user_id');
$this->addSql('DROP INDEX user_language');
$this->addSql('DROP INDEX user_archived');
$this->addSql('DROP INDEX user_starred');
$this->addSql('CREATE TEMPORARY TABLE __temp__wallabag_entry AS SELECT id, user_id, uid, title, url, hashed_url, origin_url, given_url, hashed_given_url, is_archived, archived_at, is_starred, content, created_at, updated_at, published_at, published_by, starred_at, mimetype, language, reading_time, domain_name, preview_picture, http_status, headers FROM ' . $this->getTable('entry', true));
$this->addSql('DROP TABLE ' . $this->getTable('entry', true));
@ -74,11 +78,13 @@ final class Version20190806130304 extends WallabagMigration
case 'mysql':
$this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' MODIFY language LONGTEXT DEFAULT NULL');
$this->addSql('DROP INDEX user_language ON ' . $this->getTable('entry'));
$this->addSql('DROP INDEX user_archived ON ' . $this->getTable('entry'));
$this->addSql('DROP INDEX user_starred ON ' . $this->getTable('entry'));
break;
case 'postgresql':
$this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' ALTER language TYPE TEXT');
$this->addSql('DROP INDEX user_language ON ' . $this->getTable('entry'));
$this->addSql('DROP INDEX user_archived ON ' . $this->getTable('entry'));
$this->addSql('DROP INDEX user_starred ON ' . $this->getTable('entry'));
break;
}

View file

@ -30,6 +30,7 @@ use Wallabag\UserBundle\Entity\User;
* @ORM\Index(name="hashed_url_user_id", columns={"user_id", "hashed_url"}, options={"lengths"={null, 40}}),
* @ORM\Index(name="hashed_given_url_user_id", columns={"user_id", "hashed_given_url"}, options={"lengths"={null, 40}}),
* @ORM\Index(name="user_language", columns={"language", "user_id"}),
* @ORM\Index(name="user_archived", columns={"user_id", "is_archived", "archived_at"}),
* @ORM\Index(name="user_starred", columns={"user_id", "is_starred", "starred_at"})
* }
* )