*/
private $container;
+ private $indexName = 'IDX_entry_created_at';
+
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
public function up(Schema $schema)
{
$entryTable = $schema->getTable($this->getTable('entry'));
- $entryTable->addIndex(['created_at']);
+ $this->skipIf($entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.');
+
+ $entryTable->addIndex(['created_at'], $this->indexName);
}
/**
*/
public function down(Schema $schema)
{
+ $entryTable = $schema->getTable($this->getTable('entry'));
+ $this->skipIf(false === $entryTable->hasIndex($this->indexName), 'It seems that you already played this migration.');
+
+ $entryTable->dropIndex($this->indexName);
}
}