我想知道如何完成这个方法来删除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
可以得到这样的时间Time.new(2021, 9, 7)
ConversationClass.where("created_at > ?", Time.new(2021, 9, 7)).destroy_all
应该工作。但是,在生产环境中使用它之前,您应该先在开发环境中进行测试。