summaryrefslogtreecommitdiffstats
path: root/db/migrate
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-25 11:46:19 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-02-25 11:46:19 +0000
commita98b65c2d435b3ec431edbc24bd7d6c0abc79a68 (patch)
treebeb1b4b60467280d8a12ef903299185d7db0fa6f /db/migrate
parentf01b97eb0666c7d10c4d86de584f2cfb3583652c (diff)
downloadredmine-a98b65c2d435b3ec431edbc24bd7d6c0abc79a68.tar.gz
redmine-a98b65c2d435b3ec431edbc24bd7d6c0abc79a68.zip
Fixed migration broken with Rails 3.1.3 (#10320).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8996 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20120223110929_change_attachments_container_defaults.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/db/migrate/20120223110929_change_attachments_container_defaults.rb b/db/migrate/20120223110929_change_attachments_container_defaults.rb
index 39af099f8..f959f4c33 100644
--- a/db/migrate/20120223110929_change_attachments_container_defaults.rb
+++ b/db/migrate/20120223110929_change_attachments_container_defaults.rb
@@ -1,13 +1,25 @@
class ChangeAttachmentsContainerDefaults < ActiveRecord::Migration
def self.up
+ # Need to drop the index otherwise the following error occurs in Rails 3.1.3:
+ #
+ # Index name 'temp_index_altered_attachments_on_container_id_and_container_type' on
+ # table 'altered_attachments' is too long; the limit is 64 characters
+ remove_index :attachments, [:container_id, :container_type]
+
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 = ''"
+
+ add_index :attachments, [:container_id, :container_type]
end
def self.down
+ remove_index :attachments, [:container_id, :container_type]
+
change_column :attachments, :container_id, :integer, :default => 0, :null => false
change_column :attachments, :container_type, :string, :limit => 30, :default => "", :null => false
+
+ add_index :attachments, [:container_id, :container_type]
end
end