Completed
Push — master ( 975260...d54b82 )
by Alejandro
05:50 queued 10s
created

Version20180801183328::setSize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
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 Version20180801183328 extends AbstractMigration
14
{
15
    private const NEW_SIZE = 255;
16
    private const OLD_SIZE = 10;
17
18
    /**
19
     * @param Schema $schema
20
     * @throws SchemaException
21
     */
22
    public function up(Schema $schema): void
23
    {
24
        $this->setSize($schema, self::NEW_SIZE);
25
    }
26
27
    /**
28
     * @param Schema $schema
29
     * @throws SchemaException
30
     */
31
    public function down(Schema $schema): void
32
    {
33
        $this->setSize($schema, self::OLD_SIZE);
34
    }
35
36
    /**
37
     * @param Schema $schema
38
     * @param int $size
39
     * @throws SchemaException
40
     */
41
    private function setSize(Schema $schema, int $size): void
42
    {
43
        $schema->getTable('short_urls')->getColumn('short_code')->setLength($size);
44
    }
45
}
46