Model.reset_column_information does not reload columns in rails migration

后端 未结 2 1995
长情又很酷
长情又很酷 2020-12-13 04:05

I\'m using Rails 3.2 and have a migration that contains the code:

add_column :users, :gift_aid, :integer, :default => 2
# reset columns
User.reset_column_         


        
相关标签:
2条回答
  • 2020-12-13 04:24

    this isn't needed on rails 6 (tested on 6.0.0beta3).

    I tried both with update!(new_column: ...) and update_all(new_column: ...)

    0 讨论(0)
  • 2020-12-13 04:25

    I think this must be some kind of bug related to schema caching... this might work:

    User.connection.schema_cache.clear!
    User.reset_column_information
    

    (for Rails 3.2.2)

    0 讨论(0)
提交回复
热议问题