プロジェクト

全般

プロフィール

Vote #79949

未完了

Database migrations don't run correctly for plugins when specifying the `VERSION` env variable

Admin Redmine さんが約1年前に追加. 約1年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
Plugin API_20
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
20
version_id:
32
issue_org_id:
31116
author_id:
4
assigned_to_id:
0
comments:
3
status_id:
1
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
146
ステータス-->[New]

説明

tl;dr: When comparing versions, the current_version is set to the core's latest migration instead of the plugin's latest.

Steps to reproduce:

  1. Install any plugin with migrations, for example:
    cd redmine/plugins
    git clone https://github.com/ixti/redmine_tags.git

bundle install
rake redmine:plugins:migrate NAME=redmine_tags

  1. Undo the last migration of that plugin:

    rake redmine:plugins:migrate NAME=redmine_tags VERSION=20151209153801
    
  2. Migrate to the latest version again, but specifying the version this time:

    rake redmine:plugins:migrate NAME=redmine_tags VERSION=20180122193833
    

Expected behaviour: the 20180122193833 migration is executed.
Actual behaviour: the 20180122193833 is not executed.

This is because redmine core's latest migration is 20180923091603 which is greather that the plugin's 20180122193833.

The attached fix defines a migrate method for the Redmine::Plugin::MigrationContext class that makes sure to pass along the current plugin's latest migration. Using the default migrate method defined in activerecord executes a current_version that looks for the most current migration in the list of all migrations (core and plugins).

Note: I have not run any tests with this patch.


journals

Test run available here: https://gitlab.com/sdwolfz/redmine/-/jobs/187237412

Although... I am not sure how to add a test that checks for this exact error.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
I noticed the same issue (with 4.0.2 though) and 'fixed' it another way.

--------------------------------------------------------------------------------

Admin Redmine さんが約1年前に更新

  • カテゴリPlugin API_20 にセット
  • 対象バージョンCandidate for next major release_32 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0