]> git.immae.eu Git - github/wallabag/wallabag.git/blob - app/DoctrineMigrations/Version20161104073720.php
Merge pull request #2714 from Simounet/fix/entry-card-shadow
[github/wallabag/wallabag.git] / app / DoctrineMigrations / Version20161104073720.php
1 <?php
2
3 namespace Application\Migrations;
4
5 use Doctrine\DBAL\Migrations\AbstractMigration;
6 use Doctrine\DBAL\Schema\Schema;
7 use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8 use Symfony\Component\DependencyInjection\ContainerInterface;
9
10 class Version20161104073720 extends AbstractMigration implements ContainerAwareInterface
11 {
12 /**
13 * @var ContainerInterface
14 */
15 private $container;
16
17 private $indexName = 'IDX_entry_created_at';
18
19 public function setContainer(ContainerInterface $container = null)
20 {
21 $this->container = $container;
22 }
23
24 private function getTable($tableName)
25 {
26 return $this->container->getParameter('database_table_prefix').$tableName;
27 }
28
29 /**
30 * @param Schema $schema
31 */
32 public function up(Schema $schema)
33 {
34 $entryTable = $schema->getTable($this->getTable('entry'));
35 $this->skipIf($entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.');
36
37 $entryTable->addIndex(['created_at'], $this->indexName);
38 }
39
40 /**
41 * @param Schema $schema
42 */
43 public function down(Schema $schema)
44 {
45 $entryTable = $schema->getTable($this->getTable('entry'));
46 $this->skipIf(false === $entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.');
47
48 $entryTable->dropIndex($this->indexName);
49 }
50 }