Sha256: d850fc6fb9a204287ebf7a97966153c9763dc21e83d2acec4d8405a0be1688b2
Contents?: true
Size: 1.39 KB
Versions: 6
Compression:
Stored size: 1.39 KB
Contents
class AddATonOfBooleanFieldsToSections < ActiveRecord::Migration[5.1] def change add_column :sections, :enable_title, :boolean, default: false add_column :sections, :enable_sub_title, :boolean, default: false add_column :sections, :enable_short_description, :boolean, default: false add_column :sections, :enable_long_description, :boolean, default: false add_column :sections, :enable_button_one, :boolean, default: false add_column :sections, :enable_button_two, :boolean, default: false add_column :sections, :enable_cover_image, :boolean, default: false add_column :sections, :enable_gallery_images, :boolean, default: false begin Dhatu::Section.all.each do |section| section.enable_title = !section.title.blank? section.enable_sub_title = !section.sub_title.blank? section.enable_short_description = !section.short_description.blank? section.enable_long_description = !section.long_description.blank? section.enable_button_one = !section.button_one_text.blank? section.enable_button_two = !section.button_two_text.blank? section.enable_cover_image = !section.cover_image.blank? section.enable_gallery_images = section.gallery_images.any? section.save end rescue puts "" puts "" puts "" puts "ERROR in AddATonOfBooleanFieldsToSections".red puts "" puts "" puts "" end end end
Version data entries
6 entries across 6 versions & 1 rubygems