Adding a migration to allow for report names.

git-svn-id: file:///home/svn/framework3/trunk@13873 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Tod Beardsley 2011-10-11 18:19:23 +00:00
parent 9def293067
commit 76815d9ca8
1 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,24 @@
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