我想知道如何完成此方法,以便从2021年9月7日起删除会话类
class RemovesConversationClass < ActiveRecord::Migration[5.2]
def up
ConversationClass.where("created_at > ")destroy_all
end
def down
raise ActiveRecord::IrreversibleMigration
end
end发布于 2021-07-28 05:06:10
你可以像这样得到时间,Time.new(2021, 9, 7)
ConversationClass.where("created_at > ?", Time.new(2021, 9, 7)).destroy_all应该行得通。但是您应该先在您的开发环境中测试它,然后再将其用于生产。
https://stackoverflow.com/questions/68551455
复制相似问题