rake redmine:plugins:migrate RAILS_ENV=production を行うと Duplicate Error Column Name などのエラーが起こる

症状 

      rake redmine:plugins:migrate RAILS_ENV=production
      を実行すると、すでに存在するテーブル、あるいはすでに存在するカラムをaddしようとしてい
      る旨のエラーがでる。

原因

DB移行作業時に'schema_migrations'の移行がされていなかったため、現行データベースの状況にあった適切なMigrationが実行できない。

対処

yaml_db のソースコードを修正する:

vi ./.rvm/gems/ruby-1.9.3-p286/gems/yaml_db-0.2.3/lib/serialization_helper.rb
161行目ぐらいにある

ActiveRecord::Base.connection.tables.reject { |table| ['schema_info', 'schema_migrations'].include?(table) }
ActiveRecord::Base.connection.tables.reject { |table| ['schema_info'].include?(table) } 
    とする。


コメント

このブログの人気の投稿

AppSheet の Data Source に Heroku Postgres を追加したい