diff --git a/data/migrations/Version20201023090929.php b/data/migrations/Version20201023090929.php new file mode 100644 index 00000000..49a401ba --- /dev/null +++ b/data/migrations/Version20201023090929.php @@ -0,0 +1,33 @@ +getTable('short_urls'); + $this->skipIf($shortUrls->hasColumn(self::IMPORT_SOURCE_COLUMN)); + + $shortUrls->addColumn(self::IMPORT_SOURCE_COLUMN, Types::STRING, [ + 'length' => 255, + 'notnull' => false, + ]); + } + + public function down(Schema $schema): void + { + $shortUrls = $schema->getTable('short_urls'); + $this->skipIf(! $shortUrls->hasColumn(self::IMPORT_SOURCE_COLUMN)); + + $shortUrls->dropColumn(self::IMPORT_SOURCE_COLUMN); + } +} diff --git a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.ShortUrl.php b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.ShortUrl.php index 871ac113..55fa230e 100644 --- a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.ShortUrl.php +++ b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.ShortUrl.php @@ -51,6 +51,11 @@ return static function (ClassMetadata $metadata, array $emConfig): void { ->nullable() ->build(); + $builder->createField('importSource', Types::STRING) + ->columnName('import_source') + ->nullable() + ->build(); + $builder->createOneToMany('visits', Entity\Visit::class) ->mappedBy('shortUrl') ->fetchExtraLazy() diff --git a/module/Core/src/Entity/ShortUrl.php b/module/Core/src/Entity/ShortUrl.php index 6da6562a..34883127 100644 --- a/module/Core/src/Entity/ShortUrl.php +++ b/module/Core/src/Entity/ShortUrl.php @@ -35,7 +35,7 @@ class ShortUrl extends AbstractEntity private ?Domain $domain = null; private bool $customSlugWasProvided; private int $shortCodeLength; - private ?string $source = null; + private ?string $importSource = null; public function __construct( string $longUrl, @@ -72,7 +72,7 @@ class ShortUrl extends AbstractEntity } $instance = new self($url->longUrl(), ShortUrlMeta::fromRawData($meta), $domainResolver); - $instance->source = $source; + $instance->importSource = $source; $instance->dateCreated = Chronos::instance($url->createdAt()); return $instance;