Code Duplication    Length = 17-23 lines in 2 locations

src/Migrations/Version20150615114646.php 2 locations

@@ 25-47 (lines=23) @@
22
        $this->container = $container;
23
    }
24
25
    public function up(Schema $schema)
26
    {
27
        $gatewaySchema    = $this->getGatewaySchema();
28
        $middlewareSchema = $this->getMiddlewareSchema();
29
        $middlewareUser   = $this->getMiddlewareUser();
30
31
        // this up() migration is auto-generated, please modify it to your needs
32
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
33
34
        $this->addSql(sprintf(
35
            'CREATE TABLE %s.whitelist_entry (institution VARCHAR(255) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
36
            $middlewareSchema
37
        ));
38
        $this->addSql(sprintf(
39
            'CREATE TABLE %s.whitelist_entry (institution VARCHAR(255) NOT NULL, PRIMARY KEY(institution)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB',
40
            $gatewaySchema
41
        ));
42
        $this->addSql(sprintf(
43
            'GRANT DELETE,INSERT,SELECT,UPDATE ON %s.whitelist_entry TO %s',
44
            $gatewaySchema,
45
            $middlewareUser
46
        ));
47
    }
48
49
    public function down(Schema $schema)
50
    {
@@ 49-65 (lines=17) @@
46
        ));
47
    }
48
49
    public function down(Schema $schema)
50
    {
51
        $gatewaySchema    = $this->getGatewaySchema();
52
        $middlewareSchema = $this->getMiddlewareSchema();
53
        $middlewareUser   = $this->getMiddlewareUser();
54
55
        // this down() migration is auto-generated, please modify it to your needs
56
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.');
57
58
        $this->addSql(sprintf(
59
            'REVOKE DELETE,INSERT,SELECT,UPDATE ON %s.whitelist_entry FROM %s',
60
            $gatewaySchema,
61
            $middlewareUser
62
        ));
63
        $this->addSql(sprintf('DROP TABLE %s.saml_entity', $middlewareSchema));
64
        $this->addSql(sprintf('DROP TABLE %s.saml_entity', $gatewaySchema));
65
    }
66
67
    private function getGatewaySchema()
68
    {