| Total Complexity | 6 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | final class Version20200105165647 extends AbstractMigration |
||
| 14 | { |
||
| 15 | private const COLUMNS = ['latitude', 'longitude']; |
||
| 16 | |||
| 17 | public function preUp(Schema $schema): void |
||
| 18 | { |
||
| 19 | foreach (self::COLUMNS as $columnName) { |
||
| 20 | $qb = $this->connection->createQueryBuilder(); |
||
| 21 | $qb->update('visit_locations') |
||
| 22 | ->set($columnName, '"0"') |
||
| 23 | ->where($columnName . '=""') |
||
| 24 | ->orWhere($columnName . ' IS NULL') |
||
| 25 | ->execute(); |
||
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @throws DBALException |
||
| 31 | */ |
||
| 32 | public function up(Schema $schema): void |
||
| 33 | { |
||
| 34 | $visitLocations = $schema->getTable('visit_locations'); |
||
| 35 | |||
| 36 | foreach (self::COLUMNS as $columnName) { |
||
| 37 | $visitLocations->getColumn($columnName)->setType(Type::getType(Types::FLOAT)); |
||
| 38 | } |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @throws DBALException |
||
| 43 | */ |
||
| 44 | public function down(Schema $schema): void |
||
| 50 | } |
||
| 51 | } |
||
| 52 | } |
||
| 53 |