1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Surfnet\StepupMiddleware\Migrations; |
4
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Migrations\AbstractMigration; |
6
|
|
|
use Doctrine\DBAL\Schema\Schema; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Auto-generated Migration: Please modify to your needs! |
10
|
|
|
*/ |
11
|
|
|
class Version20181023151546 extends AbstractMigration |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @param Schema $schema |
15
|
|
|
*/ |
16
|
|
|
public function up(Schema $schema) |
17
|
|
|
{ |
18
|
|
|
// this up() migration is auto-generated, please modify it to your needs |
19
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
20
|
|
|
|
21
|
|
|
$this->addSql('ALTER TABLE ra_listing DROP PRIMARY KEY'); |
22
|
|
|
$this->addSql('ALTER TABLE ra_listing ADD id INT AUTO_INCREMENT PRIMARY KEY NOT NULL FIRST, ADD ra_institution VARCHAR(255) NOT NULL COMMENT \'(DC2Type:institution)\''); |
23
|
|
|
$this->addSql('CREATE UNIQUE INDEX idx_ra_listing_unique_identity_institution ON ra_listing (identity_id, ra_institution)'); |
24
|
|
|
$this->addSql('ALTER TABLE ra_candidate DROP PRIMARY KEY'); |
25
|
|
|
$this->addSql('ALTER TABLE ra_candidate ADD ra_institution VARCHAR(255) NOT NULL COMMENT \'(DC2Type:institution)\''); |
26
|
|
|
$this->addSql('CREATE UNIQUE INDEX idx_ra_candidate_unique_identity_institution ON ra_candidate (identity_id, ra_institution)'); |
27
|
|
|
$this->addSql('ALTER TABLE ra_candidate ADD id INT FIRST'); |
28
|
|
|
$this->addSql('ALTER TABLE ra_candidate ADD INDEX(`id`)'); |
29
|
|
|
$this->addSql('ALTER TABLE ra_candidate CHANGE id id INT NOT NULL AUTO_INCREMENT'); |
30
|
|
|
$this->addSql('ALTER TABLE ra_candidate ADD PRIMARY KEY (id)'); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param Schema $schema |
35
|
|
|
*/ |
36
|
|
|
public function down(Schema $schema) |
37
|
|
|
{ |
38
|
|
|
$this->throwIrreversibleMigrationException('This migration is irreversible and cannot be reverted due to Fine Grained Authorization BC changes.'); |
39
|
|
|
|
40
|
|
|
// this down() migration is auto-generated, please modify it to your needs |
41
|
|
|
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.'); |
42
|
|
|
|
43
|
|
|
$this->addSql('ALTER TABLE ra_candidate MODIFY id INT NOT NULL'); |
44
|
|
|
$this->addSql('DROP INDEX idx_ra_candidate_unique_identity_institution ON ra_candidate'); |
45
|
|
|
$this->addSql('ALTER TABLE ra_candidate DROP PRIMARY KEY'); |
46
|
|
|
$this->addSql('ALTER TABLE ra_candidate DROP id, DROP ra_institution'); |
47
|
|
|
$this->addSql('ALTER TABLE ra_candidate ADD PRIMARY KEY (identity_id)'); |
48
|
|
|
$this->addSql('ALTER TABLE ra_listing MODIFY id INT NOT NULL'); |
49
|
|
|
$this->addSql('DROP INDEX idx_ra_listing_unique_identity_institution ON ra_listing'); |
50
|
|
|
$this->addSql('ALTER TABLE ra_listing DROP PRIMARY KEY'); |
51
|
|
|
$this->addSql('ALTER TABLE ra_listing DROP id, DROP ra_institution'); |
52
|
|
|
$this->addSql('ALTER TABLE ra_listing ADD PRIMARY KEY (identity_id)'); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function postUp(Schema $schema) |
56
|
|
|
{ |
57
|
|
|
$this->connection->executeQuery('UPDATE ra_listing SET ra_institution=institution'); |
58
|
|
|
$this->connection->executeQuery('UPDATE ra_candidate SET ra_institution=institution'); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|