| Total Complexity | 3 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 10 | final class Version20250526153605_HistoryWithLocation extends AbstractMigration |
||
| 11 | { |
||
| 12 | public function getDescription(): string |
||
| 13 | { |
||
| 14 | return 'Adds optional location reference to history entries.'; |
||
| 15 | } |
||
| 16 | |||
| 17 | public function up(Schema $schema): void |
||
| 18 | { |
||
| 19 | $this->addSql(<<<'SQL' |
||
| 20 | ALTER TABLE stu_history ADD location_id INT DEFAULT NULL |
||
| 21 | SQL); |
||
| 22 | $this->addSql(<<<'SQL' |
||
| 23 | ALTER TABLE stu_history ADD CONSTRAINT FK_7F01683964D218E FOREIGN KEY (location_id) REFERENCES stu_location (id) NOT DEFERRABLE INITIALLY IMMEDIATE |
||
| 24 | SQL); |
||
| 25 | $this->addSql(<<<'SQL' |
||
| 26 | CREATE INDEX IDX_7F01683964D218E ON stu_history (location_id) |
||
| 27 | SQL); |
||
| 28 | } |
||
| 29 | |||
| 30 | public function down(Schema $schema): void |
||
| 31 | { |
||
| 32 | $this->addSql(<<<'SQL' |
||
| 33 | ALTER TABLE stu_history DROP CONSTRAINT FK_7F01683964D218E |
||
| 34 | SQL); |
||
| 35 | $this->addSql(<<<'SQL' |
||
| 36 | DROP INDEX IDX_7F01683964D218E |
||
| 37 | SQL); |
||
| 38 | $this->addSql(<<<'SQL' |
||
| 39 | ALTER TABLE stu_history DROP location_id |
||
| 43 |