Completed
Pull Request — master (#243)
by Alejandro
01:35
created

Version20181020065148   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 10 3
A down() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace ShlinkMigrations;
5
6
use Doctrine\DBAL\Schema\Schema;
7
use Doctrine\DBAL\Schema\SchemaException;
8
use Doctrine\Migrations\AbstractMigration;
9
10
/**
11
 * Auto-generated Migration: Please modify to your needs!
12
 */
13
final class Version20181020065148 extends AbstractMigration
14
{
15
    private const CAMEL_CASE_COLUMNS = [
16
        'countryCode',
17
        'countryName',
18
        'regionName',
19
        'cityName',
20
    ];
21
22
    /**
23
     * @throws SchemaException
24
     */
25
    public function up(Schema $schema): void
26
    {
27
        $visitLocations = $schema->getTable('visit_locations');
28
29
        foreach (self::CAMEL_CASE_COLUMNS as $name) {
30
            if ($visitLocations->hasColumn($name)) {
31
                $visitLocations->dropColumn($name);
32
            }
33
        }
34
    }
35
36
    public function down(Schema $schema): void
37
    {
38
        // No down
39
    }
40
}
41