aboutsummaryrefslogtreecommitdiffhomepage
path: root/app/DoctrineMigrations/Version20170127093841.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2017-01-27 14:46:50 +0100
committerGitHub <noreply@github.com>2017-01-27 14:46:50 +0100
commitf0c5154d68108e5ec829ee9346fb20b702d9444f (patch)
treefa5a32d4f73cb2740a871230d9685bbeb50f269d /app/DoctrineMigrations/Version20170127093841.php
parent6fb06904ecde15b1b07d0a2af945338b416cf0e2 (diff)
parent01e760691b72b3c3e63ac79a18da2c8efad42558 (diff)
downloadwallabag-f0c5154d68108e5ec829ee9346fb20b702d9444f.tar.gz
wallabag-f0c5154d68108e5ec829ee9346fb20b702d9444f.tar.zst
wallabag-f0c5154d68108e5ec829ee9346fb20b702d9444f.zip
Merge pull request #2789 from wallabag/add-index-starred-archived
Added indexes on is_archived and is_starred
Diffstat (limited to 'app/DoctrineMigrations/Version20170127093841.php')
-rw-r--r--app/DoctrineMigrations/Version20170127093841.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/app/DoctrineMigrations/Version20170127093841.php b/app/DoctrineMigrations/Version20170127093841.php
new file mode 100644
index 00000000..20c79479
--- /dev/null
+++ b/app/DoctrineMigrations/Version20170127093841.php
@@ -0,0 +1,56 @@
1<?php
2
3namespace Application\Migrations;
4
5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface;
9
10/**
11 * Added indexes on wallabag_entry.is_starred and wallabag_entry.is_archived
12 */
13class Version20170127093841 extends AbstractMigration implements ContainerAwareInterface
14{
15 /**
16 * @var ContainerInterface
17 */
18 private $container;
19
20 private $indexStarredName = 'IDX_entry_starred';
21 private $indexArchivedName = 'IDX_entry_archived';
22
23 public function setContainer(ContainerInterface $container = null)
24 {
25 $this->container = $container;
26 }
27
28 private function getTable($tableName)
29 {
30 return $this->container->getParameter('database_table_prefix').$tableName;
31 }
32
33 /**
34 * @param Schema $schema
35 */
36 public function up(Schema $schema)
37 {
38 $entryTable = $schema->getTable($this->getTable('entry'));
39 $this->skipIf($entryTable->hasIndex($this->indexStarredName) && $entryTable->hasIndex($this->indexArchivedName), 'It seems that you already played this migration.');
40
41 $entryTable->addIndex(['is_starred'], $this->indexStarredName);
42 $entryTable->addIndex(['is_archived'], $this->indexArchivedName);
43 }
44
45 /**
46 * @param Schema $schema
47 */
48 public function down(Schema $schema)
49 {
50 $entryTable = $schema->getTable($this->getTable('entry'));
51 $this->skipIf(false === $entryTable->hasIndex($this->indexStarredName) && false === $entryTable->hasIndex($this->indexArchivedName), 'It seems that you already played this migration.');
52
53 $entryTable->dropIndex($this->indexStarredName);
54 $entryTable->dropIndex($this->indexArchivedName);
55 }
56}