Преглед изворни кода

Merge pull request #1025 from acelaya-forks/feature/wrong-skip-migration

Feature/wrong skip migration
Alejandro Celaya пре 3 година
родитељ
комит
4df4db05f4
2 измењених фајлова са 21 додато и 6 уклоњено
  1. 17 0
      CHANGELOG.md
  2. 4 6
      data/migrations/Version20210207100807.php

+ 17 - 0
CHANGELOG.md

@@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
 
 The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).
 
+## [Unreleased]
+### Added
+* *Nothing*
+
+### Changed
+* *Nothing*
+
+### Deprecated
+* *Nothing*
+
+### Removed
+* *Nothing*
+
+### Fixed
+* [#1024](https://github.com/shlinkio/shlink/issues/1024) Fixed migration that is incorrectly skipped due to the wrong condition being used to check it.
+
+
 ## [2.6.0] - 2021-02-13
 ### Added
 * [#856](https://github.com/shlinkio/shlink/issues/856) Added PHP 8.0 support.

+ 4 - 6
data/migrations/Version20210207100807.php

@@ -15,10 +15,9 @@ final class Version20210207100807 extends AbstractMigration
     public function up(Schema $schema): void
     {
         $visits = $schema->getTable('visits');
-        $shortUrlId = $visits->getColumn('short_url_id');
-
-        $this->skipIf(! $shortUrlId->getNotnull());
+        $this->skipIf($visits->hasColumn('visited_url'));
 
+        $shortUrlId = $visits->getColumn('short_url_id');
         $shortUrlId->setNotnull(false);
 
         $visits->addColumn('visited_url', Types::STRING, [
@@ -34,10 +33,9 @@ final class Version20210207100807 extends AbstractMigration
     public function down(Schema $schema): void
     {
         $visits = $schema->getTable('visits');
-        $shortUrlId = $visits->getColumn('short_url_id');
-
-        $this->skipIf($shortUrlId->getNotnull());
+        $this->skipIf(! $visits->hasColumn('visited_url'));
 
+        $shortUrlId = $visits->getColumn('short_url_id');
         $shortUrlId->setNotnull(true);
         $visits->dropColumn('visited_url');
         $visits->dropColumn('type');