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
![]() |
|||
43 | } |
||
44 | } |
||
45 |