summaryrefslogtreecommitdiffstats
path: root/db/migrate/20120223110929_change_attachments_container_defaults.rb
blob: 39af099f8dc439449e23a5d981dc1afc085cbb3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
class ChangeAttachmentsContainerDefaults < ActiveRecord::Migration
  def self.up
    change_column :attachments, :container_id, :integer, :default => nil, :null => true
    change_column :attachments, :container_type, :string, :limit => 30, :default => nil, :null => true
    Attachment.update_all "container_id = NULL", "container_id = 0"
    Attachment.update_all "container_type = NULL", "container_type = ''"
  end

  def self.down
    change_column :attachments, :container_id, :integer, :default => 0, :null => false
    change_column :attachments, :container_type, :string, :limit => 30, :default => "", :null => false
  end
end