Completed
Push — feature/test-php-7-2-in-travis ( 027341...a56bae )
by
unknown
05:31
created

Version20150522164907::down()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Surfnet\StepupMiddleware\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
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13 View Code Duplication
class Version20150522164907 extends AbstractMigration implements ContainerAwareInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
    /**
16
     * @var ContainerInterface
17
     */
18
    private $container;
19
20
    public function setContainer(ContainerInterface $container = null)
21
    {
22
        $this->container = $container;
23
    }
24
25
    /**
26
     * @param Schema $schema
27
     */
28
    public function up(Schema $schema)
29
    {
30
        $gatewaySchema = $this->getGatewaySchema();
31
32
        // this up() migration is auto-generated, please modify it to your needs
33
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
34
35
        $this->addSql(sprintf('CREATE UNIQUE INDEX unq_saml_entity_entity_id_type ON %s.saml_entity (entity_id, type)', $gatewaySchema));
36
    }
37
38
    /**
39
     * @param Schema $schema
40
     */
41
    public function down(Schema $schema)
42
    {
43
        $gatewaySchema = $this->getGatewaySchema();
44
45
        // this down() migration is auto-generated, please modify it to your needs
46
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
47
48
        $this->addSql(sprintf('DROP INDEX unq_saml_entity_entity_id_type ON %s.saml_entity', $gatewaySchema));
49
    }
50
51
    private function getGatewaySchema()
52
    {
53
        return $this->container->getParameter('database_gateway_name');
54
    }
55
}
56