mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Fixed short codes DB length too short
This commit is contained in:
parent
a79c1f580e
commit
3883ed15c4
44
data/migrations/Version20180801183328.php
Normal file
44
data/migrations/Version20180801183328.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace ShlinkMigrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\DBAL\Schema\SchemaException;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20180801183328 extends AbstractMigration
|
||||
{
|
||||
private const NEW_SIZE = 255;
|
||||
private const OLD_SIZE = 10;
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
* @throws SchemaException
|
||||
*/
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
$this->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);
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ class ShortUrl extends AbstractEntity implements \JsonSerializable
|
||||
* name="short_code",
|
||||
* type="string",
|
||||
* nullable=false,
|
||||
* length=10,
|
||||
* length=255,
|
||||
* unique=true
|
||||
* )
|
||||
*/
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user