3 namespace Application\Migrations
;
5 use Doctrine\DBAL\Migrations\AbstractMigration
;
6 use Doctrine\DBAL\Schema\Schema
;
7 use Symfony\Component\DependencyInjection\ContainerAwareInterface
;
8 use Symfony\Component\DependencyInjection\ContainerInterface
;
10 class Version20161104073720
extends AbstractMigration
implements ContainerAwareInterface
13 * @var ContainerInterface
17 private $indexName = 'IDX_entry_created_at';
19 public function setContainer(ContainerInterface
$container = null)
21 $this->container
= $container;
24 private function getTable($tableName)
26 return $this->container
->getParameter('database_table_prefix').$tableName;
30 * @param Schema $schema
32 public function up(Schema
$schema)
34 $entryTable = $schema->getTable($this->getTable('entry'));
35 $this->skipIf($entryTable->hasIndex($this->indexName
), 'It seems that you already played this migration.');
37 $entryTable->addIndex(['created_at'], $this->indexName
);
41 * @param Schema $schema
43 public function down(Schema
$schema)
45 $entryTable = $schema->getTable($this->getTable('entry'));
46 $this->skipIf(false === $entryTable->hasIndex($this->indexName
), 'It seems that you already played this migration.');
48 $entryTable->dropIndex($this->indexName
);