Total Complexity | 4 |
Total Lines | 28 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
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 |
||
43 | } |
||
44 | } |
||
45 |