Rails migration: best way to retrieve current migration version

后端 未结 4 990
梦谈多话
梦谈多话 2021-01-30 03:06

Is there good way to retrieve migration version number?

I need to implement a method in a model which behave differently on and beyond a specific migration version.

4条回答
  •  长情又很酷
    2021-01-30 03:25

    For Rails 5.x/6.x:

    puts ApplicationRecord.connection.migration_context.current_version
    puts ApplicationRecord.connection.migration_context.get_all_versions
    

提交回复
热议问题