Sha256: ae8741d0f84531fdb86d3e8f6378d5e2a5a82270adc8bc8cef8e709f96dd36e3

Contents?: true

Size: 1.13 KB

Versions: 34

Compression:

Stored size: 1.13 KB

Contents

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.where("container_id = 0").update_all("container_id = NULL")
    Attachment.where("container_type = ''").update_all("container_type = NULL")

    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

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
redmine_extensions-0.0.39 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.0.38 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.0.37 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.1.11 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.1.10 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.0.36 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.0.34 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.1.09 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.1.07 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.1.06 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.1.05 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.1.04 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.1.03 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.0.33 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.1.02 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.1.01 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.0.29 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.0.28 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.0.27 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb
redmine_extensions-0.0.24 spec/redmine/db/migrate/20120223110929_change_attachments_container_defaults.rb