educoder/db/migrate/20191014061301_migrate_cour...

8 lines
312 B

class MigrateCourseAtta < ActiveRecord::Migration[5.2]
def change
add_column :attachments, :delay_publish, :boolean, default: 0
Attachment.where(container_type: "Course").where(is_publish: 0).where("publish_time > '#{(Time.now).strftime("%Y-%m-%d %H:%M:%S")}'").update_all(delay_publish: 1)
end
end