| Conditions | 1 |
| Paths | 1 |
| Total Lines | 115 |
| Code Lines | 104 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 17 | public function up(Schema $schema): void |
||
| 18 | { |
||
| 19 | // CREATE NEW TABLES |
||
| 20 | $this->createSpacecraft(); |
||
| 21 | $this->createShip(); |
||
| 22 | $this->createStation(); |
||
| 23 | $this->createTrumfield(); |
||
| 24 | |||
| 25 | // MOVE DATA |
||
| 26 | $this->fillSpacecraft(); |
||
| 27 | $this->fillShip(); |
||
| 28 | $this->fillStation(); |
||
| 29 | $this->fillTrumfield(); |
||
| 30 | $this->extendExistingData(); |
||
| 31 | |||
| 32 | // ADD CONSTRAINTS |
||
| 33 | $this->addConstraints(); |
||
| 34 | |||
| 35 | // REFACTORING |
||
| 36 | $this->addSql('ALTER TABLE stu_colonies_shipqueue DROP CONSTRAINT FK_BEDCCA2FC256317D'); |
||
| 37 | $this->addSql('ALTER TABLE stu_colonies_shipqueue ADD CONSTRAINT FK_BEDCCA2FC256317D FOREIGN KEY (ship_id) REFERENCES stu_ship (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 38 | $this->addSql('ALTER TABLE stu_colonies_shiprepair DROP CONSTRAINT FK_F14F182FC256317D'); |
||
| 39 | $this->addSql('ALTER TABLE stu_colonies_shiprepair ADD CONSTRAINT FK_F14F182FC256317D FOREIGN KEY (ship_id) REFERENCES stu_ship (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 40 | $this->addSql('ALTER TABLE stu_construction_progress DROP CONSTRAINT fk_57d2ad04c256317d'); |
||
| 41 | $this->addSql('DROP INDEX uniq_57d2ad04c256317d'); |
||
| 42 | $this->addSql('DROP INDEX construction_progress_ship_idx'); |
||
| 43 | $this->addSql('ALTER TABLE stu_construction_progress RENAME COLUMN ship_id TO station_id'); |
||
| 44 | $this->addSql('ALTER TABLE stu_construction_progress ADD CONSTRAINT FK_57D2AD0421BDB235 FOREIGN KEY (station_id) REFERENCES stu_station (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 45 | $this->addSql('CREATE UNIQUE INDEX UNIQ_57D2AD0421BDB235 ON stu_construction_progress (station_id)'); |
||
| 46 | $this->addSql('ALTER TABLE stu_crew_assign DROP CONSTRAINT fk_2ca6e80ac907e695'); |
||
| 47 | $this->addSql('DROP INDEX ship_crew_ship_idx'); |
||
| 48 | $this->addSql('ALTER TABLE stu_crew_assign RENAME COLUMN ship_id TO spacecraft_id'); |
||
| 49 | $this->addSql('ALTER TABLE stu_crew_assign ADD CONSTRAINT FK_4793ED241C6AF6FD FOREIGN KEY (spacecraft_id) REFERENCES stu_spacecraft (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 50 | $this->addSql('CREATE INDEX ship_crew_spacecraft_idx ON stu_crew_assign (spacecraft_id)'); |
||
| 51 | $this->addSql('ALTER TABLE stu_dockingrights DROP CONSTRAINT fk_e7d4b2ac907e695'); |
||
| 52 | $this->addSql('DROP INDEX dockingrights_ship_idx'); |
||
| 53 | $this->addSql('ALTER TABLE stu_dockingrights RENAME COLUMN ships_id TO station_id'); |
||
| 54 | $this->addSql('ALTER TABLE stu_dockingrights ADD CONSTRAINT FK_E7D4B2A21BDB235 FOREIGN KEY (station_id) REFERENCES stu_station (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 55 | $this->addSql('CREATE INDEX dockingrights_station_idx ON stu_dockingrights (station_id)'); |
||
| 56 | $this->addSql('ALTER TABLE stu_fleets DROP CONSTRAINT FK_2042261BC907E695'); |
||
| 57 | $this->addSql('ALTER TABLE stu_fleets ADD CONSTRAINT FK_2042261BC907E695 FOREIGN KEY (ships_id) REFERENCES stu_ship (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 58 | $this->addSql('ALTER TABLE stu_mining_queue DROP CONSTRAINT FK_BBFEF8C4C256317D'); |
||
| 59 | $this->addSql('ALTER TABLE stu_mining_queue ADD CONSTRAINT FK_BBFEF8C4C256317D FOREIGN KEY (ship_id) REFERENCES stu_ship (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 60 | $this->addSql('ALTER TABLE stu_repair_task DROP CONSTRAINT FK_36DA3BAFC256317D'); |
||
| 61 | $this->addSql('DROP INDEX idx_36da3bafc256317d'); |
||
| 62 | $this->addSql('ALTER TABLE stu_repair_task RENAME COLUMN ship_id TO spacecraft_id'); |
||
| 63 | $this->addSql('ALTER TABLE stu_repair_task ADD CONSTRAINT FK_36DA3BAFC256317D FOREIGN KEY (spacecraft_id) REFERENCES stu_spacecraft (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 64 | $this->addSql('CREATE INDEX IDX_36DA3BAF1C6AF6FD ON stu_repair_task (spacecraft_id)'); |
||
| 65 | $this->addSql('ALTER TABLE stu_rumps_categories DROP points'); |
||
| 66 | $this->addSql('ALTER TABLE stu_ship_log DROP CONSTRAINT fk_74cef0eec256317d'); |
||
| 67 | $this->addSql('DROP INDEX ship_log_ship_idx'); |
||
| 68 | $this->addSql('ALTER TABLE stu_ship_log RENAME COLUMN ship_id TO spacecraft_id'); |
||
| 69 | $this->addSql('ALTER TABLE stu_ship_log ADD CONSTRAINT FK_74CEF0EE1C6AF6FD FOREIGN KEY (spacecraft_id) REFERENCES stu_spacecraft (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 70 | $this->addSql('CREATE INDEX IDX_74CEF0EE1C6AF6FD ON stu_ship_log (spacecraft_id)'); |
||
| 71 | $this->addSql('ALTER TABLE stu_ship_system DROP CONSTRAINT fk_fc8bbeb7c907e695'); |
||
| 72 | $this->addSql('DROP INDEX ship_system_ship_idx'); |
||
| 73 | $this->addSql('ALTER TABLE stu_ship_system RENAME COLUMN ship_id TO spacecraft_id'); |
||
| 74 | $this->addSql('ALTER TABLE stu_ship_system ADD CONSTRAINT FK_8E777AE91C6AF6FD FOREIGN KEY (spacecraft_id) REFERENCES stu_spacecraft (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 75 | $this->addSql('CREATE INDEX IDX_8E777AE91C6AF6FD ON stu_ship_system (spacecraft_id)'); |
||
| 76 | $this->addSql('ALTER INDEX ship_system_module_idx RENAME TO IDX_8E777AE9AFC2B591'); |
||
| 77 | $this->addSql('ALTER TABLE stu_ship_takeover DROP CONSTRAINT fk_4b0b8a7c8b898915'); |
||
| 78 | $this->addSql('ALTER TABLE stu_ship_takeover DROP CONSTRAINT fk_4b0b8a7c93e8816'); |
||
| 79 | $this->addSql('DROP INDEX uniq_4b0b8a7c93e8816'); |
||
| 80 | $this->addSql('DROP INDEX uniq_4b0b8a7c8b898915'); |
||
| 81 | $this->addSql('DROP INDEX ship_takeover_target_idx'); |
||
| 82 | $this->addSql('DROP INDEX ship_takeover_source_idx'); |
||
| 83 | $this->addSql('ALTER TABLE stu_ship_takeover RENAME COLUMN source_ship_id TO source_spacecraft_id'); |
||
| 84 | $this->addSql('ALTER TABLE stu_ship_takeover RENAME COLUMN target_ship_id TO target_spacecraft_id'); |
||
| 85 | $this->addSql('ALTER TABLE stu_ship_takeover ADD CONSTRAINT FK_4B0B8A7CD906279F FOREIGN KEY (source_spacecraft_id) REFERENCES stu_spacecraft (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 86 | $this->addSql('ALTER TABLE stu_ship_takeover ADD CONSTRAINT FK_4B0B8A7CE6C54C FOREIGN KEY (target_spacecraft_id) REFERENCES stu_spacecraft (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 87 | $this->addSql('CREATE UNIQUE INDEX UNIQ_4B0B8A7CD906279F ON stu_ship_takeover (source_spacecraft_id)'); |
||
| 88 | $this->addSql('CREATE UNIQUE INDEX UNIQ_4B0B8A7CE6C54C ON stu_ship_takeover (target_spacecraft_id)'); |
||
| 89 | $this->addSql('CREATE INDEX ship_takeover_target_idx ON stu_ship_takeover (target_spacecraft_id)'); |
||
| 90 | $this->addSql('CREATE INDEX ship_takeover_source_idx ON stu_ship_takeover (source_spacecraft_id)'); |
||
| 91 | $this->addSql('ALTER TABLE stu_shipyard_shipqueue DROP CONSTRAINT fk_7c6ffb42c256317d'); |
||
| 92 | $this->addSql('DROP INDEX idx_7c6ffb42c256317d'); |
||
| 93 | $this->addSql('ALTER TABLE stu_shipyard_shipqueue RENAME COLUMN ship_id TO station_id'); |
||
| 94 | $this->addSql('ALTER TABLE stu_shipyard_shipqueue ADD CONSTRAINT FK_7C6FFB4221BDB235 FOREIGN KEY (station_id) REFERENCES stu_station (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 95 | $this->addSql('CREATE INDEX IDX_7C6FFB4221BDB235 ON stu_shipyard_shipqueue (station_id)'); |
||
| 96 | $this->addSql('ALTER TABLE stu_spacecraft_emergency DROP CONSTRAINT FK_F0230813C256317D'); |
||
| 97 | $this->addSql('DROP INDEX spacecraft_emergency_ship_idx'); |
||
| 98 | $this->addSql('ALTER TABLE stu_spacecraft_emergency RENAME COLUMN ship_id TO spacecraft_id'); |
||
| 99 | $this->addSql('ALTER TABLE stu_spacecraft_emergency ADD CONSTRAINT FK_F0230813C256317D FOREIGN KEY (spacecraft_id) REFERENCES stu_spacecraft (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 100 | $this->addSql('CREATE INDEX IDX_F02308131C6AF6FD ON stu_spacecraft_emergency (spacecraft_id)'); |
||
| 101 | $this->addSql('ALTER TABLE stu_station_shiprepair DROP CONSTRAINT FK_51875AF721BDB235'); |
||
| 102 | $this->addSql('ALTER TABLE stu_station_shiprepair DROP CONSTRAINT FK_51875AF7C256317D'); |
||
| 103 | $this->addSql('ALTER TABLE stu_station_shiprepair ADD CONSTRAINT FK_51875AF721BDB235 FOREIGN KEY (station_id) REFERENCES stu_station (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 104 | $this->addSql('ALTER TABLE stu_station_shiprepair ADD CONSTRAINT FK_51875AF7C256317D FOREIGN KEY (ship_id) REFERENCES stu_ship (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 105 | $this->addSql('ALTER TABLE stu_storage DROP CONSTRAINT FK_CC10346C256317D'); |
||
| 106 | $this->addSql('DROP INDEX storage_ship_idx'); |
||
| 107 | $this->addSql('ALTER TABLE stu_storage RENAME COLUMN ship_id TO spacecraft_id'); |
||
| 108 | $this->addSql('ALTER TABLE stu_storage ADD trumfield_id INT DEFAULT NULL'); |
||
| 109 | $this->addSql('ALTER TABLE stu_storage ADD CONSTRAINT FK_CC10346668E6720 FOREIGN KEY (trumfield_id) REFERENCES stu_trumfield (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 110 | $this->addSql('ALTER TABLE stu_storage ADD CONSTRAINT FK_CC103461C6AF6FD FOREIGN KEY (spacecraft_id) REFERENCES stu_spacecraft (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 111 | $this->addSql('CREATE INDEX IDX_CC10346668E6720 ON stu_storage (trumfield_id)'); |
||
| 112 | $this->addSql('CREATE INDEX storage_spacecraft_idx ON stu_storage (spacecraft_id)'); |
||
| 113 | $this->addSql('ALTER TABLE stu_tholian_web DROP CONSTRAINT FK_D032F9A0C256317D'); |
||
| 114 | $this->addSql('ALTER TABLE stu_tholian_web ADD CONSTRAINT FK_D032F9A0C256317D FOREIGN KEY (ship_id) REFERENCES stu_ship (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 115 | $this->addSql('ALTER TABLE stu_torpedo_storage DROP CONSTRAINT fk_82371911c256317d'); |
||
| 116 | $this->addSql('DROP INDEX uniq_82371911c256317d'); |
||
| 117 | $this->addSql('DROP INDEX torpedo_storage_ship_idx'); |
||
| 118 | $this->addSql('ALTER TABLE stu_torpedo_storage RENAME COLUMN ship_id TO spacecraft_id'); |
||
| 119 | $this->addSql('ALTER TABLE stu_torpedo_storage ADD CONSTRAINT FK_823719111C6AF6FD FOREIGN KEY (spacecraft_id) REFERENCES stu_spacecraft (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 120 | $this->addSql('CREATE UNIQUE INDEX UNIQ_823719111C6AF6FD ON stu_torpedo_storage (spacecraft_id)'); |
||
| 121 | $this->addSql('CREATE INDEX torpedo_storage_spacecraft_idx ON stu_torpedo_storage (spacecraft_id)'); |
||
| 122 | $this->addSql('ALTER TABLE stu_trade_posts DROP CONSTRAINT fk_13d25e73c256317d'); |
||
| 123 | $this->addSql('DROP INDEX uniq_13d25e73c256317d'); |
||
| 124 | $this->addSql('DROP INDEX trade_post_ship_idx'); |
||
| 125 | $this->addSql('ALTER TABLE stu_trade_posts RENAME COLUMN ship_id TO station_id'); |
||
| 126 | $this->addSql('ALTER TABLE stu_trade_posts ADD CONSTRAINT FK_13D25E7321BDB235 FOREIGN KEY (station_id) REFERENCES stu_station (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); |
||
| 127 | $this->addSql('CREATE UNIQUE INDEX UNIQ_13D25E7321BDB235 ON stu_trade_posts (station_id)'); |
||
| 128 | $this->addSql('CREATE INDEX trade_post_station_idx ON stu_trade_posts (station_id)'); |
||
| 129 | |||
| 130 | // DROP OLD TABLES |
||
| 131 | $this->dropStuShips(); |
||
| 132 | } |
||
| 263 |