2016-08-19 15:51:34 +03:00
|
|
|
<?php
|
2019-10-05 18:26:10 +03:00
|
|
|
|
2017-10-12 11:13:20 +03:00
|
|
|
declare(strict_types=1);
|
2016-08-19 15:51:34 +03:00
|
|
|
|
|
|
|
namespace ShlinkMigrations;
|
|
|
|
|
2019-03-09 20:45:58 +03:00
|
|
|
use Doctrine\DBAL\DBALException;
|
2016-08-19 15:51:34 +03:00
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
2019-03-09 20:45:58 +03:00
|
|
|
use Doctrine\DBAL\Schema\SchemaException;
|
|
|
|
use Doctrine\Migrations\AbstractMigration;
|
2016-08-19 15:51:34 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Auto-generated Migration: Please modify to your needs!
|
|
|
|
*/
|
|
|
|
class Version20160819142757 extends AbstractMigration
|
|
|
|
{
|
2019-03-09 20:45:58 +03:00
|
|
|
private const MYSQL = 'mysql';
|
|
|
|
private const SQLITE = 'sqlite';
|
2016-08-19 15:51:34 +03:00
|
|
|
|
|
|
|
/**
|
2019-03-09 20:45:58 +03:00
|
|
|
* @throws DBALException
|
|
|
|
* @throws SchemaException
|
2016-08-19 15:51:34 +03:00
|
|
|
*/
|
2019-03-09 20:45:58 +03:00
|
|
|
public function up(Schema $schema): void
|
2016-08-19 15:51:34 +03:00
|
|
|
{
|
|
|
|
$db = $this->connection->getDatabasePlatform()->getName();
|
|
|
|
$table = $schema->getTable('short_urls');
|
|
|
|
$column = $table->getColumn('short_code');
|
|
|
|
|
|
|
|
if ($db === self::MYSQL) {
|
|
|
|
$column->setPlatformOption('collation', 'utf8_bin');
|
|
|
|
} elseif ($db === self::SQLITE) {
|
2016-08-19 16:15:53 +03:00
|
|
|
$column->setPlatformOption('collate', 'BINARY');
|
2016-08-19 15:51:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-03-09 20:45:58 +03:00
|
|
|
* @throws DBALException
|
2016-08-19 15:51:34 +03:00
|
|
|
*/
|
2019-03-09 20:45:58 +03:00
|
|
|
public function down(Schema $schema): void
|
2016-08-19 15:51:34 +03:00
|
|
|
{
|
|
|
|
$db = $this->connection->getDatabasePlatform()->getName();
|
|
|
|
}
|
|
|
|
}
|