shlink/data/migrations/Version20160819142757.php

48 lines
1.2 KiB
PHP
Raw Normal View History

<?php
2019-10-05 18:26:10 +03:00
2017-10-12 11:13:20 +03:00
declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\Schema;
2019-03-09 20:45:58 +03:00
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\Migrations\AbstractMigration;
use function get_class;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20160819142757 extends AbstractMigration
{
/**
* @throws Exception
2019-03-09 20:45:58 +03:00
* @throws SchemaException
*/
2019-03-09 20:45:58 +03:00
public function up(Schema $schema): void
{
$platformClass = get_class($this->connection->getDatabasePlatform());
$table = $schema->getTable('short_urls');
$column = $table->getColumn('short_code');
match ($platformClass) {
MySQLPlatform::class => $column->setPlatformOption('collation', 'utf8_bin'),
SqlitePlatform::class => $column->setPlatformOption('collate', 'BINARY'),
default => null,
};
}
2019-03-09 20:45:58 +03:00
public function down(Schema $schema): void
{
// Nothing to roll back
}
public function isTransactional(): bool
{
return ! ($this->connection->getDatabasePlatform() instanceof MySQLPlatform);
}
}