Sha256: ebd3d8f13a82168b4ac3218b2b33f07920a38b5bc627e02c30c4c77d708d20e4
Contents?: true
Size: 505 Bytes
Versions: 88
Compression:
Stored size: 505 Bytes
Contents
class AddDisplayNameToReportsTable < ActiveRecord::Migration class Report < ActiveRecord::Base end def self.up add_column :reports, :name, :string, :limit => 63 # Migrate to have a default name. Report.find(:all).each do |report| rtype = report.rtype.to_s =~ /^([A-Z0-9]+)\x2d/i ? $1 : "AUDIT" default_name = rtype[0,57].downcase.capitalize + "-" + report.id.to_s[0,5] report.name = default_name report.save end end def self.down remove_column :reports, :name end end
Version data entries
88 entries across 88 versions & 1 rubygems