plugins:migrate マイグレートがスキップされている様に見える

475 views
Skip to first unread message

sioaj...@gmail.com

unread,
Jun 1, 2022, 10:48:30 PM6/1/22
to Redmine Users (japanese)
こんにちは。しおあじ と申します。
redmine_checklists-3_1_21-light をインストールしようとしています。

プラグインのマイグレートがスキップされている様に見えるのですが、原因が判らず困っています。
どなたかヒントなどいただけますと助かります。。。
どうぞよろしくお願い致します。。

■マイグレート
C:\Bitnami\redmine-4.2.3-4\apps\redmine\htdocs>bundle exec rake redmine:plugins:migrate RAILS_ENV=production --trace
** Invoke redmine:plugins:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute redmine:plugins:migrate
== 3 CreateChecklistTemplateCategory: migrating ===============================
-- create_table(:checklist_template_categories, {:options=>"ENGINE=InnoDB", :id=>:integer})
   -> 0.3549s
== 3 CreateChecklistTemplateCategory: migrated (0.3590s) ======================

== 4 CreateChecklistTemplates: migrating ======================================
-- create_table(:checklist_templates, {:options=>"ENGINE=InnoDB", :id=>:integer})
   -> 0.2208s
== 4 CreateChecklistTemplates: migrated (0.2245s) =============================

== 5 ModifyChecklistSubjectLength: migrating ==================================
-- change_column(:checklists, :subject, :string, {:limit=>512})
rake aborted!
StandardError: An error has occurred, all later migrations canceled:

Mysql2::Error: Table 'bitnami_redmine.checklists' doesn't exist: SHOW FULL FIELDS FROM `checklists`


★下記の最初Step001で テーブル checklists が作成されず
 Step005でエラーになった様に見えます。

■\redmine_checklists\db\migrate フォルダ内のファイル
----------------------------------------------------------------------------------------
001_create_checklists.rb ★スキップされてる?
002_add_time_stamps_to_checklists.rb ★スキップされてる?
003_create_checklist_template_category.rb
004_create_checklist_templates.rb
005_modify_checklist_subject_length.rb
006_add_fields_to_checklist_template.rb
007_add_is_section_to_checklists.rb
----------------------------------------------------------------------------------------

■001_create_checklists.rbの内容です。
----------------------------------------------------------------------------------------
class CreateChecklists < Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]

  def self.up
    if ActiveRecord::Base.connection.table_exists? :issue_checklists
      rename_table :issue_checklists, :checklists
    else
      create_table :checklists do |t|
        t.boolean :is_done, :default => false
        t.string :subject
        t.integer :position, :default => 1
        t.references :issue, :null => false
      end
    end
  end

  def self.down
    drop_table :checklists
  end
end
----------------------------------------------------------------------------------------
・Rails version 5.2.6
・issue_checklistsというテーブルは、あったのですが、dropして削除しました。
・試しに、下記の様に▲の行を削除してみましたが、同じ結果でした。
-------------------------------------
  def self.up
▲if ActiveRecord::Base.connection.table_exists? :issue_checklists 
▲  rename_table :issue_checklists, :checklists
▲else
      create_table :checklists do |t|
        t.boolean :is_done, :default => false
        t.string :subject
        t.integer :position, :default => 1
        t.references :issue, :null => false
▲  end
    end
  end
-------------------------------------

以上です。

前田剛

unread,
Jun 2, 2022, 5:57:40 AM6/2/22
to redmine-...@googlegroups.com
前田といいます。

On Thu, Jun 2, 2022 at 11:48 AM sioaj...@gmail.com <sioaj...@gmail.com> wrote:
>
> こんにちは。しおあじ と申します。
> redmine_checklists-3_1_21-light をインストールしようとしています。
>
> プラグインのマイグレートがスキップされている様に見えるのですが、原因が判らず困っています。

どのマイグレーションを実行したのかは schema_migrations
というテーブルで管理されています。おそらく、schema_migrations
内に当該プラグインのバージョン1と2のマイグレーションを実行した記録はあるのにも関わらず、テーブルが存在しない状態なのではないかと思います(例えば手作業でDROP
TABLEしたとか)。

`select * from schema_migrations;`
したら当該プラグイン関係っぽい行が見つかると思います。それらの行を削除するとマイグレーションが最初から実行されるのではないかと思います。

--
// 前田 剛 <ma...@farend.jp>

sioaj...@gmail.com

unread,
Jun 2, 2022, 11:41:03 PM6/2/22
to Redmine Users (japanese)
解決しました。
前田さん、ご連絡どうもありがとうございます。

`select * from schema_migrations;` のversionというカラムに 1-redmine_checklists とありました。
これを削除しましたら、マイグレーション実行完了出来ました。

少し前にchecklists のテーブルを手作業でDROP TABLEしていました。

とても助かりました。どうもありがとうございます!

以下は、マイグレーションが通ったログになります。
C:\Bitnami\redmine-4.2.3-4\apps\redmine\htdocs>bundle exec rake redmine:plugins:migrate RAILS_ENV=production --trace
** Invoke redmine:plugins:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute redmine:plugins:migrate
== 1 CreateChecklists: migrating ==============================================
-- create_table(:checklists, {:options=>"ENGINE=InnoDB", :id=>:integer})
   -> 0.2589s
== 1 CreateChecklists: migrated (0.2710s) =====================================


== 3 CreateChecklistTemplateCategory: migrating ===============================
-- create_table(:checklist_template_categories, {:options=>"ENGINE=InnoDB", :id=>:integer})
   -> 0.2557s
== 3 CreateChecklistTemplateCategory: migrated (0.2597s) ======================


== 4 CreateChecklistTemplates: migrating ======================================
-- create_table(:checklist_templates, {:options=>"ENGINE=InnoDB", :id=>:integer})
   -> 0.1721s
== 4 CreateChecklistTemplates: migrated (0.1761s) =============================


== 5 ModifyChecklistSubjectLength: migrating ==================================
-- change_column(:checklists, :subject, :string, {:limit=>512})
   -> 0.1599s
== 5 ModifyChecklistSubjectLength: migrated (0.1638s) =========================

== 6 AddFieldsToChecklistTemplate: migrating ==================================
-- add_column(:checklist_templates, :is_default, :boolean, {:default=>false})
   -> 0.0592s
-- add_column(:checklist_templates, :tracker_id, :integer, {})
   -> 0.0609s
-- add_index(:checklist_templates, :tracker_id)
   -> 0.1579s
== 6 AddFieldsToChecklistTemplate: migrated (0.2900s) =========================

== 7 AddIsSectionToChecklists: migrating ======================================
-- add_column(:checklists, :is_section, :boolean, {:default=>false})
   -> 0.0554s
== 7 AddIsSectionToChecklists: migrated (0.0594s) =============================

** Invoke db:schema:dump (first_time)
** Invoke db:load_config (first_time)
** Invoke environment
** Execute db:load_config
** Execute db:schema:dump


C:\Bitnami\redmine-4.2.3-4\apps\redmine\htdocs>
以上になります。
2022年6月2日木曜日 18:57:40 UTC+9 前田 剛:
Reply all
Reply to author
Forward
0 new messages