From b9eb9cb6d9c877f016a0329cb42b2c846cf18b34 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Fri, 3 Jan 2020 11:38:21 +0100 Subject: [PATCH 1/8] Updated all shlink packages but installer to their latest version --- composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 8a1b075f..1b7c89c2 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "guzzlehttp/guzzle": "^6.5.1", "laminas/laminas-config": "^3.3", "laminas/laminas-config-aggregator": "^1.1", - "laminas/laminas-dependency-plugin": "^0.2", + "laminas/laminas-dependency-plugin": "^1.0", "laminas/laminas-diactoros": "^2.1.3", "laminas/laminas-inputfilter": "^2.10", "laminas/laminas-paginator": "^2.8", @@ -47,10 +47,10 @@ "phly/phly-event-dispatcher": "^1.0", "predis/predis": "^1.1", "pugx/shortid-php": "^0.5", - "shlinkio/shlink-common": "^2.4", - "shlinkio/shlink-event-dispatcher": "^1.1", + "shlinkio/shlink-common": "^2.5", + "shlinkio/shlink-event-dispatcher": "^1.3", "shlinkio/shlink-installer": "^3.3", - "shlinkio/shlink-ip-geolocation": "^1.2", + "shlinkio/shlink-ip-geolocation": "^1.3", "symfony/console": "^5.0", "symfony/filesystem": "^5.0", "symfony/lock": "^5.0", @@ -64,7 +64,7 @@ "phpunit/phpunit": "^8.3", "roave/security-advisories": "dev-master", "shlinkio/php-coding-standard": "~2.1.0", - "shlinkio/shlink-test-utils": "^1.2", + "shlinkio/shlink-test-utils": "^1.3", "symfony/var-dumper": "^5.0" }, "autoload": { From f3f35218c333df5fc484aa3169fbadfd484ef05c Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 4 Jan 2020 13:18:28 +0100 Subject: [PATCH 2/8] Updated to installer v4 --- bin/install | 4 +- bin/update | 4 +- composer.json | 2 +- config/autoload/installer.global.php | 71 ++++++++++++---------------- 4 files changed, 36 insertions(+), 45 deletions(-) diff --git a/bin/install b/bin/install index 5918cac0..d20db86d 100755 --- a/bin/install +++ b/bin/install @@ -8,5 +8,5 @@ use function chdir; use function dirname; chdir(dirname(__DIR__)); -$run = require __DIR__ . '/../vendor/shlinkio/shlink-installer/bin/run.php'; -$run(false); +[$install] = require __DIR__ . '/../vendor/shlinkio/shlink-installer/bin/run.php'; +$install(); diff --git a/bin/update b/bin/update index 5dd32e72..ad20ce46 100755 --- a/bin/update +++ b/bin/update @@ -8,5 +8,5 @@ use function chdir; use function dirname; chdir(dirname(__DIR__)); -$run = require __DIR__ . '/../vendor/shlinkio/shlink-installer/bin/run.php'; -$run(true); +[, $update] = require __DIR__ . '/../vendor/shlinkio/shlink-installer/bin/run.php'; +$update(); diff --git a/composer.json b/composer.json index 1b7c89c2..80c29769 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,7 @@ "pugx/shortid-php": "^0.5", "shlinkio/shlink-common": "^2.5", "shlinkio/shlink-event-dispatcher": "^1.3", - "shlinkio/shlink-installer": "^3.3", + "shlinkio/shlink-installer": "^4.0", "shlinkio/shlink-ip-geolocation": "^1.3", "symfony/console": "^5.0", "symfony/filesystem": "^5.0", diff --git a/config/autoload/installer.global.php b/config/autoload/installer.global.php index 402e6bb3..63716906 100644 --- a/config/autoload/installer.global.php +++ b/config/autoload/installer.global.php @@ -2,51 +2,42 @@ declare(strict_types=1); -use Shlinkio\Shlink\Installer\Config\Plugin; +use Shlinkio\Shlink\Installer\Config\Option; return [ - 'installer_plugins_expected_config' => [ - Plugin\UrlShortenerConfigCustomizer::class => [ - Plugin\UrlShortenerConfigCustomizer::SCHEMA, - Plugin\UrlShortenerConfigCustomizer::HOSTNAME, - Plugin\UrlShortenerConfigCustomizer::VALIDATE_URL, - Plugin\UrlShortenerConfigCustomizer::NOTIFY_VISITS_WEBHOOKS, - Plugin\UrlShortenerConfigCustomizer::VISITS_WEBHOOKS, + 'installer' => [ + 'enabled_options' => [ + Option\DatabaseDriverConfigOption::class, + Option\DatabaseNameConfigOption::class, + Option\DatabaseHostConfigOption::class, + Option\DatabasePortConfigOption::class, + Option\DatabaseUserConfigOption::class, + Option\DatabasePasswordConfigOption::class, + Option\DatabaseSqlitePathConfigOption::class, + Option\DatabaseMySqlOptionsConfigOption::class, + Option\ShortDomainHostConfigOption::class, + Option\ShortDomainSchemaConfigOption::class, + Option\ValidateUrlConfigOption::class, + Option\VisitsWebhooksConfigOption::class, + Option\BaseUrlRedirectConfigOption::class, + Option\InvalidShortUrlRedirectConfigOption::class, + Option\Regular404RedirectConfigOption::class, + Option\DisableTrackParamConfigOption::class, + Option\CheckVisitsThresholdConfigOption::class, + Option\VisitsThresholdConfigOption::class, + Option\BasePathConfigOption::class, + Option\TaskWorkerNumConfigOption::class, + Option\WebWorkerNumConfigOption::class, ], - Plugin\ApplicationConfigCustomizer::class => [ - Plugin\ApplicationConfigCustomizer::SECRET, - Plugin\ApplicationConfigCustomizer::DISABLE_TRACK_PARAM, - Plugin\ApplicationConfigCustomizer::CHECK_VISITS_THRESHOLD, - Plugin\ApplicationConfigCustomizer::VISITS_THRESHOLD, - Plugin\ApplicationConfigCustomizer::BASE_PATH, - Plugin\ApplicationConfigCustomizer::WEB_WORKER_NUM, - Plugin\ApplicationConfigCustomizer::TASK_WORKER_NUM, - ], - - Plugin\DatabaseConfigCustomizer::class => [ - Plugin\DatabaseConfigCustomizer::DRIVER, - Plugin\DatabaseConfigCustomizer::NAME, - Plugin\DatabaseConfigCustomizer::USER, - Plugin\DatabaseConfigCustomizer::PASSWORD, - Plugin\DatabaseConfigCustomizer::HOST, - Plugin\DatabaseConfigCustomizer::PORT, - ], - - Plugin\RedirectsConfigCustomizer::class => [ - Plugin\RedirectsConfigCustomizer::INVALID_SHORT_URL_REDIRECT_TO, - Plugin\RedirectsConfigCustomizer::REGULAR_404_REDIRECT_TO, - Plugin\RedirectsConfigCustomizer::BASE_URL_REDIRECT_TO, - ], - ], - - 'installation_commands' => [ - 'db_create_schema' => [ - 'command' => 'bin/cli db:create', - ], - 'db_migrate' => [ - 'command' => 'bin/cli db:migrate', + 'installation_commands' => [ + 'db_create_schema' => [ + 'command' => 'bin/cli db:create', + ], + 'db_migrate' => [ + 'command' => 'bin/cli db:migrate', + ], ], ], From abe54c67d8bfbbd1f75e3a4da4131c830c5c9379 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 4 Jan 2020 13:21:37 +0100 Subject: [PATCH 3/8] Updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d95519d7..cb9c59e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this * [#429](https://github.com/shlinkio/shlink/issues/429) Added support for PHP 7.4 * [#529](https://github.com/shlinkio/shlink/issues/529) Created an UPGRADING.md file explaining how to upgrade from v1.x to v2.x +* [#594](https://github.com/shlinkio/shlink/issues/594) Updated external shlink packages, including installer v4.0, which adds the option to ask for the redis cluster config. #### Changed From 4fadd523f193d568e558c1e5b52643b8807599d4 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 5 Jan 2020 16:45:14 +0100 Subject: [PATCH 4/8] Updated config to read redis from config.redis --- config/autoload/redis.local.php.local | 13 ++++++++----- docker/config/shlink_in_docker.local.php | 10 ++++++++-- module/Core/src/Config/SimplifiedConfigParser.php | 2 +- .../Core/test/Config/SimplifiedConfigParserTest.php | 10 ++++++---- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/config/autoload/redis.local.php.local b/config/autoload/redis.local.php.local index f89201f1..08dbae32 100644 --- a/config/autoload/redis.local.php.local +++ b/config/autoload/redis.local.php.local @@ -1,13 +1,16 @@ [ - 'servers' => 'tcp://shlink_redis:6379', -// 'servers' => [ -// 'tcp://shlink_redis:6379', -// ], + 'cache' => [ + 'redis' => [ + 'servers' => 'tcp://shlink_redis:6379', +// 'servers' => [ +// 'tcp://shlink_redis:6379', +// ], + ], ], 'dependencies' => [ diff --git a/docker/config/shlink_in_docker.local.php b/docker/config/shlink_in_docker.local.php index 0da6a9e5..7eba5560 100644 --- a/docker/config/shlink_in_docker.local.php +++ b/docker/config/shlink_in_docker.local.php @@ -62,6 +62,12 @@ $helper = new class { $webhooks = env('VISITS_WEBHOOKS'); return $webhooks === null ? [] : explode(',', $webhooks); } + + public function getRedisConfig(): ?array + { + $redisServers = env('REDIS_SERVERS'); + return $redisServers === null ? null : ['servers' => $redisServers]; + } }; return [ @@ -112,8 +118,8 @@ return [ ], ], - 'redis' => [ - 'servers' => env('REDIS_SERVERS'), + 'cache' => [ + 'redis' => $helper->getRedisConfig(), ], 'router' => [ diff --git a/module/Core/src/Config/SimplifiedConfigParser.php b/module/Core/src/Config/SimplifiedConfigParser.php index 651066d4..fa7a4acb 100644 --- a/module/Core/src/Config/SimplifiedConfigParser.php +++ b/module/Core/src/Config/SimplifiedConfigParser.php @@ -27,7 +27,7 @@ class SimplifiedConfigParser 'base_url_redirect_to' => ['not_found_redirects', 'base_path'], 'db_config' => ['entity_manager', 'connection'], 'delete_short_url_threshold' => ['delete_short_urls', 'visits_threshold'], - 'redis_servers' => ['redis', 'servers'], + 'redis_servers' => ['cache', 'redis', 'servers'], 'base_path' => ['router', 'base_path'], 'web_worker_num' => ['mezzio-swoole', 'swoole-http-server', 'options', 'worker_num'], 'task_worker_num' => ['mezzio-swoole', 'swoole-http-server', 'options', 'task_worker_num'], diff --git a/module/Core/test/Config/SimplifiedConfigParserTest.php b/module/Core/test/Config/SimplifiedConfigParserTest.php index d92399cf..1d4f3b8d 100644 --- a/module/Core/test/Config/SimplifiedConfigParserTest.php +++ b/module/Core/test/Config/SimplifiedConfigParserTest.php @@ -97,10 +97,12 @@ class SimplifiedConfigParserTest extends TestCase ], ], - 'redis' => [ - 'servers' => [ - 'tcp://1.1.1.1:1111', - 'tcp://1.2.2.2:2222', + 'cache' => [ + 'redis' => [ + 'servers' => [ + 'tcp://1.1.1.1:1111', + 'tcp://1.2.2.2:2222', + ], ], ], From 2e0f8067aa59a1c32cd4ec5b5a66547ed2ec9b56 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 5 Jan 2020 17:04:22 +0100 Subject: [PATCH 5/8] Enabled redis config option --- config/autoload/installer.global.php | 1 + 1 file changed, 1 insertion(+) diff --git a/config/autoload/installer.global.php b/config/autoload/installer.global.php index 63716906..296c0635 100644 --- a/config/autoload/installer.global.php +++ b/config/autoload/installer.global.php @@ -29,6 +29,7 @@ return [ Option\BasePathConfigOption::class, Option\TaskWorkerNumConfigOption::class, Option\WebWorkerNumConfigOption::class, + Option\RedisServersConfigOption::class, ], 'installation_commands' => [ From 7748dd7cef3916d292d0477714e039110a0ff876 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 6 Jan 2020 22:31:00 +0100 Subject: [PATCH 6/8] Ensured latitude and longitude are set as float in DB --- data/migrations/Version20200105165647.php | 52 +++++++++++++++++++ ...inkio.Shlink.Core.Entity.VisitLocation.php | 16 ++++-- module/Core/src/Entity/Visit.php | 6 +-- 3 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 data/migrations/Version20200105165647.php diff --git a/data/migrations/Version20200105165647.php b/data/migrations/Version20200105165647.php new file mode 100644 index 00000000..838a6f70 --- /dev/null +++ b/data/migrations/Version20200105165647.php @@ -0,0 +1,52 @@ +connection->createQueryBuilder(); + $qb->update('visit_locations') + ->set($columnName, '"0"') + ->where($columnName . '=""') + ->orWhere($columnName . ' IS NULL') + ->execute(); + } + } + + /** + * @throws DBALException + */ + public function up(Schema $schema): void + { + $visitLocations = $schema->getTable('visit_locations'); + + foreach (self::COLUMNS as $columnName) { + $visitLocations->getColumn($columnName)->setType(Type::getType(Types::FLOAT)); + } + } + + /** + * @throws DBALException + */ + public function down(Schema $schema): void + { + $visitLocations = $schema->getTable('visit_locations'); + + foreach (self::COLUMNS as $columnName) { + $visitLocations->getColumn($columnName)->setType(Type::getType(Types::STRING)); + } + } +} diff --git a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.VisitLocation.php b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.VisitLocation.php index 073214d3..decf582a 100644 --- a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.VisitLocation.php +++ b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.VisitLocation.php @@ -25,14 +25,22 @@ $columns = [ 'country_name' => 'countryName', 'region_name' => 'regionName', 'city_name' => 'cityName', - 'latitude' => 'latitude', - 'longitude' => 'longitude', 'timezone' => 'timezone', ]; foreach ($columns as $columnName => $fieldName) { $builder->createField($fieldName, Type::STRING) - ->columnName($columnName) + ->columnName($columnName) + ->nullable() + ->build(); +} + +$builder->createField('latitude', Type::FLOAT) + ->columnName('latitude') + ->nullable() + ->build(); + +$builder->createField('longitude', Type::FLOAT) + ->columnName('longitude') ->nullable() ->build(); -} diff --git a/module/Core/src/Entity/Visit.php b/module/Core/src/Entity/Visit.php index 38c17565..8ada8176 100644 --- a/module/Core/src/Entity/Visit.php +++ b/module/Core/src/Entity/Visit.php @@ -15,10 +15,10 @@ use Shlinkio\Shlink\Core\Visit\Model\VisitLocationInterface; class Visit extends AbstractEntity implements JsonSerializable { - private string $referer; + private string $referer = ''; private Chronos $date; - private ?string $remoteAddr; - private string $userAgent; + private ?string $remoteAddr = null; + private string $userAgent = ''; private ShortUrl $shortUrl; private ?VisitLocation $visitLocation = null; From 886f63d3e4ca7e5b91b12eb542e5c278ef1f968f Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 6 Jan 2020 22:57:10 +0100 Subject: [PATCH 7/8] Workarounded doctrine-dbal issue by creating new columns instead of changing column types --- data/migrations/Version20200105165647.php | 31 +++++++++++--- data/migrations/Version20200106215144.php | 41 +++++++++++++++++++ ...inkio.Shlink.Core.Entity.VisitLocation.php | 18 ++++---- 3 files changed, 75 insertions(+), 15 deletions(-) create mode 100644 data/migrations/Version20200106215144.php diff --git a/data/migrations/Version20200105165647.php b/data/migrations/Version20200105165647.php index 838a6f70..24b9f984 100644 --- a/data/migrations/Version20200105165647.php +++ b/data/migrations/Version20200105165647.php @@ -6,13 +6,12 @@ namespace ShlinkMigrations; use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Schema\Schema; -use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; use Doctrine\Migrations\AbstractMigration; final class Version20200105165647 extends AbstractMigration { - private const COLUMNS = ['latitude', 'longitude']; + private const COLUMNS = ['lat' => 'latitude', 'lon' => 'longitude']; public function preUp(Schema $schema): void { @@ -33,8 +32,28 @@ final class Version20200105165647 extends AbstractMigration { $visitLocations = $schema->getTable('visit_locations'); - foreach (self::COLUMNS as $columnName) { - $visitLocations->getColumn($columnName)->setType(Type::getType(Types::FLOAT)); + foreach (self::COLUMNS as $newName => $oldName) { + $visitLocations->addColumn($newName, Types::FLOAT); + } + } + + public function postUp(Schema $schema): void + { + foreach (self::COLUMNS as $newName => $oldName) { + $qb = $this->connection->createQueryBuilder(); + $qb->update('visit_locations') + ->set($newName, $oldName) + ->execute(); + } + } + + public function preDown(Schema $schema): void + { + foreach (self::COLUMNS as $newName => $oldName) { + $qb = $this->connection->createQueryBuilder(); + $qb->update('visit_locations') + ->set($oldName, $newName) + ->execute(); } } @@ -45,8 +64,8 @@ final class Version20200105165647 extends AbstractMigration { $visitLocations = $schema->getTable('visit_locations'); - foreach (self::COLUMNS as $columnName) { - $visitLocations->getColumn($columnName)->setType(Type::getType(Types::STRING)); + foreach (self::COLUMNS as $colName => $oldName) { + $visitLocations->dropColumn($colName); } } } diff --git a/data/migrations/Version20200106215144.php b/data/migrations/Version20200106215144.php new file mode 100644 index 00000000..8969441b --- /dev/null +++ b/data/migrations/Version20200106215144.php @@ -0,0 +1,41 @@ +getTable('visit_locations'); + + foreach (self::COLUMNS as $colName) { + $visitLocations->dropColumn($colName); + } + } + + /** + * @throws DBALException + */ + public function down(Schema $schema): void + { + $visitLocations = $schema->getTable('visit_locations'); + + foreach (self::COLUMNS as $colName) { + $visitLocations->addColumn($colName, Types::STRING, [ + 'notnull' => false, + ]); + } + } +} diff --git a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.VisitLocation.php b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.VisitLocation.php index decf582a..117c2acc 100644 --- a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.VisitLocation.php +++ b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.VisitLocation.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Shlinkio\Shlink\Core; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine @@ -13,7 +13,7 @@ $builder = new ClassMetadataBuilder($metadata); $builder->setTable('visit_locations'); -$builder->createField('id', Type::BIGINT) +$builder->createField('id', Types::BIGINT) ->columnName('id') ->makePrimaryKey() ->generatedValue('IDENTITY') @@ -29,18 +29,18 @@ $columns = [ ]; foreach ($columns as $columnName => $fieldName) { - $builder->createField($fieldName, Type::STRING) + $builder->createField($fieldName, Types::STRING) ->columnName($columnName) ->nullable() ->build(); } -$builder->createField('latitude', Type::FLOAT) - ->columnName('latitude') - ->nullable() +$builder->createField('latitude', Types::FLOAT) + ->columnName('lat') + ->nullable(false) ->build(); -$builder->createField('longitude', Type::FLOAT) - ->columnName('longitude') - ->nullable() +$builder->createField('longitude', Types::FLOAT) + ->columnName('lon') + ->nullable(false) ->build(); From 9c5f5a46b5490c0ce02ec9b3e593ade55bdefe31 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Mon, 6 Jan 2020 23:08:14 +0100 Subject: [PATCH 8/8] Replaced use of deprecated class by a non-deprecated one --- data/migrations/Version20160820191203.php | 10 +++++----- data/migrations/Version20171021093246.php | 6 +++--- data/migrations/Version20171022064541.php | 4 ++-- data/migrations/Version20181020060559.php | 4 ++-- data/migrations/Version20190930165521.php | 8 ++++---- .../Shlinkio.Shlink.Core.Entity.Domain.php | 6 +++--- .../Shlinkio.Shlink.Core.Entity.ShortUrl.php | 10 +++++----- .../Shlinkio.Shlink.Core.Entity.Tag.php | 6 +++--- .../Shlinkio.Shlink.Core.Entity.Visit.php | 10 +++++----- .../Shlinkio.Shlink.Rest.Entity.ApiKey.php | 8 ++++---- 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/data/migrations/Version20160820191203.php b/data/migrations/Version20160820191203.php index 2d8a7c38..d0a4d673 100644 --- a/data/migrations/Version20160820191203.php +++ b/data/migrations/Version20160820191203.php @@ -5,7 +5,7 @@ declare(strict_types=1); namespace ShlinkMigrations; use Doctrine\DBAL\Schema\Schema; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\Types; use Doctrine\Migrations\AbstractMigration; /** @@ -30,12 +30,12 @@ class Version20160820191203 extends AbstractMigration private function createTagsTable(Schema $schema): void { $table = $schema->createTable('tags'); - $table->addColumn('id', Type::BIGINT, [ + $table->addColumn('id', Types::BIGINT, [ 'unsigned' => true, 'autoincrement' => true, 'notnull' => true, ]); - $table->addColumn('name', Type::STRING, [ + $table->addColumn('name', Types::STRING, [ 'length' => 255, 'notnull' => true, ]); @@ -47,11 +47,11 @@ class Version20160820191203 extends AbstractMigration private function createShortUrlsInTagsTable(Schema $schema): void { $table = $schema->createTable('short_urls_in_tags'); - $table->addColumn('short_url_id', Type::BIGINT, [ + $table->addColumn('short_url_id', Types::BIGINT, [ 'unsigned' => true, 'notnull' => true, ]); - $table->addColumn('tag_id', Type::BIGINT, [ + $table->addColumn('tag_id', Types::BIGINT, [ 'unsigned' => true, 'notnull' => true, ]); diff --git a/data/migrations/Version20171021093246.php b/data/migrations/Version20171021093246.php index 6e42d775..b66a2c3f 100644 --- a/data/migrations/Version20171021093246.php +++ b/data/migrations/Version20171021093246.php @@ -6,7 +6,7 @@ namespace ShlinkMigrations; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\SchemaException; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\Types; use Doctrine\Migrations\AbstractMigration; /** @@ -24,10 +24,10 @@ class Version20171021093246 extends AbstractMigration return; } - $shortUrls->addColumn('valid_since', Type::DATETIME, [ + $shortUrls->addColumn('valid_since', Types::DATETIME, [ 'notnull' => false, ]); - $shortUrls->addColumn('valid_until', Type::DATETIME, [ + $shortUrls->addColumn('valid_until', Types::DATETIME, [ 'notnull' => false, ]); } diff --git a/data/migrations/Version20171022064541.php b/data/migrations/Version20171022064541.php index 36bfdc7b..7ff39666 100644 --- a/data/migrations/Version20171022064541.php +++ b/data/migrations/Version20171022064541.php @@ -6,7 +6,7 @@ namespace ShlinkMigrations; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\SchemaException; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\Types; use Doctrine\Migrations\AbstractMigration; /** @@ -24,7 +24,7 @@ class Version20171022064541 extends AbstractMigration return; } - $shortUrls->addColumn('max_visits', Type::INTEGER, [ + $shortUrls->addColumn('max_visits', Types::INTEGER, [ 'unsigned' => true, 'notnull' => false, ]); diff --git a/data/migrations/Version20181020060559.php b/data/migrations/Version20181020060559.php index 86d46358..5b46b6df 100644 --- a/data/migrations/Version20181020060559.php +++ b/data/migrations/Version20181020060559.php @@ -8,7 +8,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\SchemaException; use Doctrine\DBAL\Schema\Table; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\Types; use Doctrine\Migrations\AbstractMigration; /** @@ -35,7 +35,7 @@ final class Version20181020060559 extends AbstractMigration { foreach ($columnNames as $name) { if (! $visitLocations->hasColumn($name)) { - $visitLocations->addColumn($name, Type::STRING, ['notnull' => false]); + $visitLocations->addColumn($name, Types::STRING, ['notnull' => false]); } } } diff --git a/data/migrations/Version20190930165521.php b/data/migrations/Version20190930165521.php index 120f1c16..2e4e8f50 100644 --- a/data/migrations/Version20190930165521.php +++ b/data/migrations/Version20190930165521.php @@ -6,7 +6,7 @@ namespace ShlinkMigrations; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\SchemaException; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\Types; use Doctrine\Migrations\AbstractMigration; final class Version20190930165521 extends AbstractMigration @@ -22,19 +22,19 @@ final class Version20190930165521 extends AbstractMigration } $domains = $schema->createTable('domains'); - $domains->addColumn('id', Type::BIGINT, [ + $domains->addColumn('id', Types::BIGINT, [ 'unsigned' => true, 'autoincrement' => true, 'notnull' => true, ]); - $domains->addColumn('authority', Type::STRING, [ + $domains->addColumn('authority', Types::STRING, [ 'length' => 512, 'notnull' => true, ]); $domains->addUniqueIndex(['authority']); $domains->setPrimaryKey(['id']); - $shortUrls->addColumn('domain_id', Type::BIGINT, [ + $shortUrls->addColumn('domain_id', Types::BIGINT, [ 'unsigned' => true, 'notnull' => false, ]); diff --git a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Domain.php b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Domain.php index b3afe195..de7252ee 100644 --- a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Domain.php +++ b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Domain.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Shlinkio\Shlink\Core; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine @@ -13,13 +13,13 @@ $builder = new ClassMetadataBuilder($metadata); $builder->setTable('domains'); -$builder->createField('id', Type::BIGINT) +$builder->createField('id', Types::BIGINT) ->columnName('id') ->makePrimaryKey() ->generatedValue('IDENTITY') ->option('unsigned', true) ->build(); -$builder->createField('authority', Type::STRING) +$builder->createField('authority', Types::STRING) ->unique() ->build(); 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 76e5ae7b..0d24d555 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 @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Shlinkio\Shlink\Core; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine use Shlinkio\Shlink\Common\Doctrine\Type\ChronosDateTimeType; @@ -15,19 +15,19 @@ $builder = new ClassMetadataBuilder($metadata); $builder->setTable('short_urls') ->setCustomRepositoryClass(Repository\ShortUrlRepository::class); -$builder->createField('id', Type::BIGINT) +$builder->createField('id', Types::BIGINT) ->columnName('id') ->makePrimaryKey() ->generatedValue('IDENTITY') ->option('unsigned', true) ->build(); -$builder->createField('longUrl', Type::STRING) +$builder->createField('longUrl', Types::STRING) ->columnName('original_url') ->length(2048) ->build(); -$builder->createField('shortCode', Type::STRING) +$builder->createField('shortCode', Types::STRING) ->columnName('short_code') ->length(255) ->build(); @@ -46,7 +46,7 @@ $builder->createField('validUntil', ChronosDateTimeType::CHRONOS_DATETIME) ->nullable() ->build(); -$builder->createField('maxVisits', Type::INTEGER) +$builder->createField('maxVisits', Types::INTEGER) ->columnName('max_visits') ->nullable() ->build(); diff --git a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Tag.php b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Tag.php index 8ecaa2c6..09a98151 100644 --- a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Tag.php +++ b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Tag.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Shlinkio\Shlink\Core; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine @@ -14,13 +14,13 @@ $builder = new ClassMetadataBuilder($metadata); $builder->setTable('tags') ->setCustomRepositoryClass(Repository\TagRepository::class); -$builder->createField('id', Type::BIGINT) +$builder->createField('id', Types::BIGINT) ->columnName('id') ->makePrimaryKey() ->generatedValue('IDENTITY') ->option('unsigned', true) ->build(); -$builder->createField('name', Type::STRING) +$builder->createField('name', Types::STRING) ->unique() ->build(); diff --git a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Visit.php b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Visit.php index c30b83c9..6770f9d3 100644 --- a/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Visit.php +++ b/module/Core/config/entities-mappings/Shlinkio.Shlink.Core.Entity.Visit.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Shlinkio\Shlink\Core; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine use Shlinkio\Shlink\Common\Doctrine\Type\ChronosDateTimeType; @@ -16,14 +16,14 @@ $builder = new ClassMetadataBuilder($metadata); $builder->setTable('visits') ->setCustomRepositoryClass(Repository\VisitRepository::class); -$builder->createField('id', Type::BIGINT) +$builder->createField('id', Types::BIGINT) ->columnName('id') ->makePrimaryKey() ->generatedValue('IDENTITY') ->option('unsigned', true) ->build(); -$builder->createField('referer', Type::STRING) +$builder->createField('referer', Types::STRING) ->nullable() ->length(Visitor::REFERER_MAX_LENGTH) ->build(); @@ -32,13 +32,13 @@ $builder->createField('date', ChronosDateTimeType::CHRONOS_DATETIME) ->columnName('`date`') ->build(); -$builder->createField('remoteAddr', Type::STRING) +$builder->createField('remoteAddr', Types::STRING) ->columnName('remote_addr') ->length(Visitor::REMOTE_ADDRESS_MAX_LENGTH) ->nullable() ->build(); -$builder->createField('userAgent', Type::STRING) +$builder->createField('userAgent', Types::STRING) ->columnName('user_agent') ->length(Visitor::USER_AGENT_MAX_LENGTH) ->nullable() diff --git a/module/Rest/config/entities-mappings/Shlinkio.Shlink.Rest.Entity.ApiKey.php b/module/Rest/config/entities-mappings/Shlinkio.Shlink.Rest.Entity.ApiKey.php index 3b7c2e60..5bc5aec9 100644 --- a/module/Rest/config/entities-mappings/Shlinkio.Shlink.Rest.Entity.ApiKey.php +++ b/module/Rest/config/entities-mappings/Shlinkio.Shlink.Rest.Entity.ApiKey.php @@ -4,7 +4,7 @@ declare(strict_types=1); namespace Shlinkio\Shlink\Rest; -use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping\Builder\ClassMetadataBuilder; use Doctrine\ORM\Mapping\ClassMetadata; // @codingStandardsIgnoreLine use Shlinkio\Shlink\Common\Doctrine\Type\ChronosDateTimeType; @@ -14,13 +14,13 @@ $builder = new ClassMetadataBuilder($metadata); $builder->setTable('api_keys'); -$builder->createField('id', Type::BIGINT) +$builder->createField('id', Types::BIGINT) ->makePrimaryKey() ->generatedValue('IDENTITY') ->option('unsigned', true) ->build(); -$builder->createField('key', Type::STRING) +$builder->createField('key', Types::STRING) ->columnName('`key`') ->unique() ->build(); @@ -30,5 +30,5 @@ $builder->createField('expirationDate', ChronosDateTimeType::CHRONOS_DATETIME) ->nullable() ->build(); -$builder->createField('enabled', Type::BOOLEAN) +$builder->createField('enabled', Types::BOOLEAN) ->build();