Sha256: 39cc1b16d70939a8b6724d1195d8f9b23aa621970cc5d59946241a92db916fea
Contents?: true
Size: 498 Bytes
Versions: 66
Compression:
Stored size: 498 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.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
66 entries across 66 versions & 1 rubygems