LoginSignup
0
0

More than 5 years have passed since last update.

redmine pluginでmigrationエラー、pluginのmigrate管理はどうなっている?

Posted at

plugin名を変更した後、migrationをやっていこうとしたとき以下のエラーを検出。

$ rake redmine:plugins:migrate
   == 1 CreatePositions: migrating ===============================================
   -- create_table(:positions)
   rake aborted!
   StandardError: An error has occurred, this and all later migrations canceled:

   SQLite3::SQLException: table "positions" already exists: CREATE TABLE …

やろうとしたことは、既存のmodelを削除して新しいmodelを追加することだったのだが、一個目のmigrationファイルがもう一回実行されたことで、create tableがもう一回走った模様。

migrationは対象のデータベースのschema_migrationsテーブルで管理されているのだが、pluginはどう管理されているか確認してみた。それが以下の通り(どのmigrationを通したかを残す1カラムの表でした)。

[連番]-[plugin名]

なるほど、plugin名を変えるとここが合わなくなるのね。早めに気づけて良かった。
sqlでupdateすることで、うまくmigrationが通りました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0