Version20160819142757::down()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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\Schema\SchemaException;
10
use Doctrine\Migrations\AbstractMigration;
11
12
/**
13
 * Auto-generated Migration: Please modify to your needs!
14
 */
15
class Version20160819142757 extends AbstractMigration
16
{
17
    private const MYSQL = 'mysql';
18
    private const SQLITE = 'sqlite';
19
20
    /**
21
     * @throws DBALException
22
     * @throws SchemaException
23
     */
24
    public function up(Schema $schema): void
25
    {
26
        $db = $this->connection->getDatabasePlatform()->getName();
27
        $table = $schema->getTable('short_urls');
28
        $column = $table->getColumn('short_code');
29
30
        if ($db === self::MYSQL) {
31
            $column->setPlatformOption('collation', 'utf8_bin');
32
        } elseif ($db === self::SQLITE) {
33
            $column->setPlatformOption('collate', 'BINARY');
34
        }
35
    }
36
37
    /**
38
     * @throws DBALException
39
     */
40
    public function down(Schema $schema): void
41
    {
42
        $db = $this->connection->getDatabasePlatform()->getName();
0 ignored issues
show
Unused Code introduced by
The assignment to $db is dead and can be removed.
Loading history...
43
    }
44
}
45