##// END OF EJS Templates
Fixed migration broken with Rails 3.1.3 (#10320)....
Jean-Philippe Lang -
r8876:a98b65c2d435
parent child
Show More
@@ -1,13 +1,25
1 class ChangeAttachmentsContainerDefaults < ActiveRecord::Migration
1 class ChangeAttachmentsContainerDefaults < ActiveRecord::Migration
2 def self.up
2 def self.up
3 # Need to drop the index otherwise the following error occurs in Rails 3.1.3:
4 #
5 # Index name 'temp_index_altered_attachments_on_container_id_and_container_type' on
6 # table 'altered_attachments' is too long; the limit is 64 characters
7 remove_index :attachments, [:container_id, :container_type]
8
3 change_column :attachments, :container_id, :integer, :default => nil, :null => true
9 change_column :attachments, :container_id, :integer, :default => nil, :null => true
4 change_column :attachments, :container_type, :string, :limit => 30, :default => nil, :null => true
10 change_column :attachments, :container_type, :string, :limit => 30, :default => nil, :null => true
5 Attachment.update_all "container_id = NULL", "container_id = 0"
11 Attachment.update_all "container_id = NULL", "container_id = 0"
6 Attachment.update_all "container_type = NULL", "container_type = ''"
12 Attachment.update_all "container_type = NULL", "container_type = ''"
13
14 add_index :attachments, [:container_id, :container_type]
7 end
15 end
8
16
9 def self.down
17 def self.down
18 remove_index :attachments, [:container_id, :container_type]
19
10 change_column :attachments, :container_id, :integer, :default => 0, :null => false
20 change_column :attachments, :container_id, :integer, :default => 0, :null => false
11 change_column :attachments, :container_type, :string, :limit => 30, :default => "", :null => false
21 change_column :attachments, :container_type, :string, :limit => 30, :default => "", :null => false
22
23 add_index :attachments, [:container_id, :container_type]
12 end
24 end
13 end
25 end
General Comments 0
You need to be logged in to leave comments. Login now