Version20180801183328.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. declare(strict_types=1);
  3. namespace ShlinkMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\DBAL\Schema\SchemaException;
  6. use Doctrine\Migrations\AbstractMigration;
  7. /**
  8. * Auto-generated Migration: Please modify to your needs!
  9. */
  10. final class Version20180801183328 extends AbstractMigration
  11. {
  12. private const NEW_SIZE = 255;
  13. private const OLD_SIZE = 10;
  14. /**
  15. * @throws SchemaException
  16. */
  17. public function up(Schema $schema): void
  18. {
  19. $this->setSize($schema, self::NEW_SIZE);
  20. }
  21. /**
  22. * @throws SchemaException
  23. */
  24. public function down(Schema $schema): void
  25. {
  26. $this->setSize($schema, self::OLD_SIZE);
  27. }
  28. /**
  29. * @throws SchemaException
  30. */
  31. private function setSize(Schema $schema, int $size): void
  32. {
  33. $schema->getTable('short_urls')->getColumn('short_code')->setLength($size);
  34. }
  35. /**
  36. * @fixme Workaround for https://github.com/doctrine/migrations/issues/1104
  37. */
  38. public function isTransactional(): bool
  39. {
  40. return false;
  41. }
  42. }