diff --git a/data/migrations/Version20180801183328.php b/data/migrations/Version20180801183328.php new file mode 100644 index 00000000..de967de7 --- /dev/null +++ b/data/migrations/Version20180801183328.php @@ -0,0 +1,44 @@ +setSize($schema, self::NEW_SIZE); + } + + /** + * @param Schema $schema + * @throws SchemaException + */ + public function down(Schema $schema) : void + { + $this->setSize($schema, self::OLD_SIZE); + } + + /** + * @param Schema $schema + * @param int $size + * @throws SchemaException + */ + private function setSize(Schema $schema, int $size): void + { + $schema->getTable('short_urls')->getColumn('short_code')->setLength($size); + } +} diff --git a/module/Core/src/Entity/ShortUrl.php b/module/Core/src/Entity/ShortUrl.php index b1ffe60f..ff21c47b 100644 --- a/module/Core/src/Entity/ShortUrl.php +++ b/module/Core/src/Entity/ShortUrl.php @@ -29,7 +29,7 @@ class ShortUrl extends AbstractEntity implements \JsonSerializable * name="short_code", * type="string", * nullable=false, - * length=10, + * length=255, * unique=true * ) */ diff --git a/module/Core/test-func/Repository/ShortUrlRepositoryTest.php b/module/Core/test-func/Repository/ShortUrlRepositoryTest.php index 4616f6c8..184ca054 100644 --- a/module/Core/test-func/Repository/ShortUrlRepositoryTest.php +++ b/module/Core/test-func/Repository/ShortUrlRepositoryTest.php @@ -38,7 +38,7 @@ class ShortUrlRepositoryTest extends DatabaseTestCase $bar = new ShortUrl(); $bar->setOriginalUrl('bar') - ->setShortCode('bar') + ->setShortCode('bar_very_long_text') ->setValidSince((new \DateTime())->add(new \DateInterval('P1M'))); $this->getEntityManager()->persist($bar);