Total Complexity | 3 |
Total Lines | 16 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | final class Version20241113164504 extends AbstractMigration { |
||
16 | public function getDescription(): string { |
||
17 | return 'Make address change identifiers non-nullable'; |
||
18 | } |
||
19 | |||
20 | public function up( Schema $schema ): void { |
||
21 | $this->addSql( "UPDATE address_change SET previous_identifier=current_identifier WHERE previous_identifier IS NULL AND current_identifier IS NOT NULL" ); |
||
22 | // We can't use $schema here to modify the columns because `addSQL` appends to the SQL generated by $schema calls. |
||
23 | // We would fail the migration when trying to set a column to non-nullable if it already contains NULL values |
||
24 | $this->addSql( "ALTER TABLE address_change MODIFY current_identifier VARCHAR(36) NOT NULL, MODIFY previous_identifier VARCHAR(36) NOT NULL " ); |
||
25 | } |
||
26 | |||
27 | public function down( Schema $schema ): void { |
||
31 | } |
||
32 | } |
||
33 |