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
|
|
|
class Version20200114161618 extends AbstractMigration implements ContainerAwareInterface |
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
|
|
|
// Convert all available institutions occurrences to lower case (type="institution") |
31
|
|
|
$this->addSql('UPDATE audit_log SET actor_institution=LOWER(actor_institution)'); |
32
|
|
|
$this->addSql('UPDATE audit_log SET identity_institution=LOWER(identity_institution)'); |
33
|
|
|
$this->addSql('UPDATE audit_log SET ra_institution=LOWER(ra_institution)'); |
34
|
|
|
$this->addSql('UPDATE identity SET institution=LOWER(institution)'); |
35
|
|
|
$this->addSql('UPDATE institution_listing SET institution=LOWER(institution)'); |
36
|
|
|
$this->addSql('UPDATE ra_candidate SET institution=LOWER(institution)'); |
37
|
|
|
$this->addSql('UPDATE ra_candidate SET ra_institution=LOWER(ra_institution)'); |
38
|
|
|
$this->addSql('UPDATE ra_listing SET institution=LOWER(institution)'); |
39
|
|
|
$this->addSql('UPDATE ra_listing SET ra_institution=LOWER(ra_institution)'); |
40
|
|
|
$this->addSql('UPDATE ra_second_factor SET institution=LOWER(institution)'); |
41
|
|
|
$this->addSql('UPDATE second_factor_revocation SET institution=LOWER(institution)'); |
42
|
|
|
$this->addSql('UPDATE whitelist_entry SET institution=LOWER(institution)'); |
43
|
|
|
$this->addSql('UPDATE verified_second_factor SET institution=LOWER(institution)'); |
44
|
|
|
|
45
|
|
|
// Convert all available configuration institutions occurrences to lower case (type="stepup_configuration_institution") |
46
|
|
|
$this->addSql('UPDATE allowed_second_factor SET institution=LOWER(institution)'); |
47
|
|
|
$this->addSql('UPDATE configured_institution SET institution=LOWER(institution)'); |
48
|
|
|
$this->addSql('UPDATE institution_authorization SET institution=LOWER(institution)'); |
49
|
|
|
$this->addSql('UPDATE institution_authorization SET institution_relation=LOWER(institution_relation)'); |
50
|
|
|
$this->addSql('UPDATE institution_configuration_options SET institution=LOWER(institution)'); |
51
|
|
|
$this->addSql('UPDATE ra_location SET institution=LOWER(institution)'); |
52
|
|
|
|
53
|
|
|
// Convert all GW institutions to lowercase |
54
|
|
|
$gatewaySchema = $this->getGatewaySchema(); |
55
|
|
|
$this->addSql(sprintf('UPDATE %s.whitelist_entry SET institution=LOWER(institution)', $gatewaySchema)); |
56
|
|
|
$this->addSql(sprintf('UPDATE %s.second_factor SET institution=LOWER(institution)', $gatewaySchema)); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param Schema $schema |
61
|
|
|
*/ |
62
|
|
|
public function down(Schema $schema) |
63
|
|
|
{ |
64
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
65
|
|
|
|
66
|
|
|
$this->throwIrreversibleMigrationException('This migration is irreversible'); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
private function getGatewaySchema() |
70
|
|
|
{ |
71
|
|
|
return $this->container->getParameter('database_gateway_name'); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|