Version20160819142757.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. declare(strict_types=1);
  3. namespace ShlinkMigrations;
  4. use Doctrine\DBAL\Exception;
  5. use Doctrine\DBAL\Schema\Schema;
  6. use Doctrine\DBAL\Schema\SchemaException;
  7. use Doctrine\Migrations\AbstractMigration;
  8. /**
  9. * Auto-generated Migration: Please modify to your needs!
  10. */
  11. class Version20160819142757 extends AbstractMigration
  12. {
  13. private const MYSQL = 'mysql';
  14. private const SQLITE = 'sqlite';
  15. /**
  16. * @throws Exception
  17. * @throws SchemaException
  18. */
  19. public function up(Schema $schema): void
  20. {
  21. $db = $this->connection->getDatabasePlatform()->getName();
  22. $table = $schema->getTable('short_urls');
  23. $column = $table->getColumn('short_code');
  24. if ($db === self::MYSQL) {
  25. $column->setPlatformOption('collation', 'utf8_bin');
  26. } elseif ($db === self::SQLITE) {
  27. $column->setPlatformOption('collate', 'BINARY');
  28. }
  29. }
  30. /**
  31. * @throws Exception
  32. */
  33. public function down(Schema $schema): void
  34. {
  35. $db = $this->connection->getDatabasePlatform()->getName();
  36. }
  37. /**
  38. * @fixme Workaround for https://github.com/doctrine/migrations/issues/1104
  39. */
  40. public function isTransactional(): bool
  41. {
  42. return false;
  43. }
  44. }