Completed
Pull Request — develop (#599)
by Alejandro
05:40
created

Version20200106215144::down()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ShlinkMigrations;
6
7
use Doctrine\DBAL\DBALException;
8
use Doctrine\DBAL\Schema\Schema;
9
use Doctrine\DBAL\Types\Types;
10
use Doctrine\Migrations\AbstractMigration;
11
12
final class Version20200106215144 extends AbstractMigration
13
{
14
    private const COLUMNS = ['latitude', 'longitude'];
15
16
    /**
17
     * @throws DBALException
18
     */
19
    public function up(Schema $schema): void
20
    {
21
        $visitLocations = $schema->getTable('visit_locations');
22
23
        foreach (self::COLUMNS as $colName) {
24
            $visitLocations->dropColumn($colName);
25
        }
26
    }
27
28
    /**
29
     * @throws DBALException
30
     */
31
    public function down(Schema $schema): void
32
    {
33
        $visitLocations = $schema->getTable('visit_locations');
34
35
        foreach (self::COLUMNS as $colName) {
36
            $visitLocations->addColumn($colName, Types::STRING, [
37
                'notnull' => false,
38
            ]);
39
        }
40
    }
41
}
42