1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2020 SURFnet bv |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
|
|
|
|
18
|
|
|
|
19
|
|
|
namespace Surfnet\Migrations; |
20
|
|
|
|
21
|
|
|
use Doctrine\DBAL\Schema\Schema; |
22
|
|
|
use Doctrine\Migrations\AbstractMigration; |
23
|
|
|
use Surfnet\Stepup\MigrationsFactory\ConfigurationAwareMigrationInterface; |
24
|
|
|
use Surfnet\Stepup\MigrationsFactory\ConfigurationAwareMigrationTrait; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Auto-generated Migration: Please modify to your needs! |
28
|
|
|
*/ |
|
|
|
|
29
|
|
|
class Version20200114161618 extends AbstractMigration implements ConfigurationAwareMigrationInterface |
30
|
|
|
{ |
31
|
|
|
use ConfigurationAwareMigrationTrait; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param Schema $schema |
35
|
|
|
*/ |
|
|
|
|
36
|
|
|
public function up(Schema $schema): void |
37
|
|
|
{ |
38
|
|
|
// Convert all available institutions occurrences to lower case (type="institution") |
39
|
|
|
$this->addSql('UPDATE audit_log SET actor_institution=LOWER(actor_institution)'); |
40
|
|
|
$this->addSql('UPDATE audit_log SET identity_institution=LOWER(identity_institution)'); |
41
|
|
|
$this->addSql('UPDATE audit_log SET ra_institution=LOWER(ra_institution)'); |
42
|
|
|
$this->addSql('UPDATE identity SET institution=LOWER(institution)'); |
43
|
|
|
$this->addSql('UPDATE institution_listing SET institution=LOWER(institution)'); |
44
|
|
|
$this->addSql('UPDATE ra_candidate SET institution=LOWER(institution)'); |
45
|
|
|
$this->addSql('UPDATE ra_candidate SET ra_institution=LOWER(ra_institution)'); |
46
|
|
|
$this->addSql('UPDATE ra_listing SET institution=LOWER(institution)'); |
47
|
|
|
$this->addSql('UPDATE ra_listing SET ra_institution=LOWER(ra_institution)'); |
48
|
|
|
$this->addSql('UPDATE ra_second_factor SET institution=LOWER(institution)'); |
49
|
|
|
$this->addSql('UPDATE second_factor_revocation SET institution=LOWER(institution)'); |
50
|
|
|
$this->addSql('UPDATE whitelist_entry SET institution=LOWER(institution)'); |
51
|
|
|
$this->addSql('UPDATE verified_second_factor SET institution=LOWER(institution)'); |
52
|
|
|
|
53
|
|
|
// Convert all available configuration institutions occurrences to lower case (type="stepup_configuration_institution") |
54
|
|
|
$this->addSql('UPDATE allowed_second_factor SET institution=LOWER(institution)'); |
55
|
|
|
$this->addSql('UPDATE configured_institution SET institution=LOWER(institution)'); |
56
|
|
|
$this->addSql('UPDATE institution_authorization SET institution=LOWER(institution)'); |
57
|
|
|
$this->addSql('UPDATE institution_authorization SET institution_relation=LOWER(institution_relation)'); |
58
|
|
|
$this->addSql('UPDATE institution_configuration_options SET institution=LOWER(institution)'); |
59
|
|
|
$this->addSql('UPDATE ra_location SET institution=LOWER(institution)'); |
60
|
|
|
|
61
|
|
|
// Convert all GW institutions to lowercase |
62
|
|
|
$gatewaySchema = $this->getGatewaySchema(); |
63
|
|
|
$this->addSql(sprintf('UPDATE %s.whitelist_entry SET institution=LOWER(institution)', $gatewaySchema)); |
64
|
|
|
$this->addSql(sprintf('UPDATE %s.second_factor SET institution=LOWER(institution)', $gatewaySchema)); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param Schema $schema |
69
|
|
|
*/ |
|
|
|
|
70
|
|
|
public function down(Schema $schema): void |
71
|
|
|
{ |
72
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
73
|
|
|
|
74
|
|
|
$this->throwIrreversibleMigrationException('This migration is irreversible'); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|