Sha256: 2aa0bf67d05c42db957ca57d8f0fe7eae39c9bc6bbdd7cfa0bcb48a14e7d07d7
Contents?: true
Size: 494 Bytes
Versions: 8
Compression:
Stored size: 494 Bytes
Contents
class AddSectionTypeIdToSections < ActiveRecord::Migration[5.1] def change add_reference :sections, :section_type, index: true begin Dhatu::Section.all.each do |section| section_type = Dhatu::SectionType.find_by_code(section.section_type) || Dhatu::SectionType.create(title: section.section_type.titleize, code: section.section_type) section.update_attribute(section_type_id: section_type.id) end rescue end remove_column :sections, :section_type end end
Version data entries
8 entries across 8 versions & 1 rubygems