Sha256: 17b29fe9f2e4e2a34e17e63c4e6cdbb63af3069cba98ba63c99ce01e967d1700

Contents?: true

Size: 427 Bytes

Versions: 6

Compression:

Stored size: 427 Bytes

Contents

class AddNameToSections < ActiveRecord::Migration[5.1]
  def change
  	add_column :sections, :name, :string, null: false, limit: 64
  	begin
	  	Dhatu::Section.all.each do |section|
	      section.name = section.code.titleize.gsub("_", " ") if section.code
	      section.save
	    end
	  rescue
	  	puts ""
	  	puts ""
	  	puts ""
	  	puts "ERROR in AddNameToSections".red
	  	puts ""
	  	puts ""
	  	puts ""
	  end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dhatu-0.1.25 db/migrate/20180101093442_add_name_to_sections.rb
dhatu-0.1.24 db/migrate/20180101093442_add_name_to_sections.rb
dhatu-0.1.23 db/migrate/20180101093442_add_name_to_sections.rb
dhatu-0.1.22 db/migrate/20180101093442_add_name_to_sections.rb
dhatu-0.1.21 db/migrate/20180101093442_add_name_to_sections.rb
dhatu-0.1.20 db/migrate/20180101093442_add_name_to_sections.rb