Makes container_id and container_type columns nullables.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8934 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-02-23 11:15:39 +00:00
parent afa6c1a9a7
commit 10a37e2769
1 changed files with 13 additions and 0 deletions

View File

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