Sha256: cfd71683b896ab096f53344c50f7a559c629392513e9ff34a8e980b2545672c4

Contents?: true

Size: 852 Bytes

Versions: 42

Compression:

Stored size: 852 Bytes

Contents

class <%= migration_class_name %> < ActiveRecord::Migration
  def self.up
    if index_exists? :audits, [:association_id, :association_type], :name => 'association_index'
      remove_index :audits, :name => 'association_index'
    end

    rename_column :audits, :association_id, :associated_id
    rename_column :audits, :association_type, :associated_type

    add_index :audits, [:associated_id, :associated_type], :name => 'associated_index'
  end

  def self.down
    if index_exists? :audits, [:associated_id, :associated_type], :name => 'associated_index'
      remove_index :audits, :name => 'associated_index'
    end

    rename_column :audits, :associated_type, :association_type
    rename_column :audits, :associated_id, :association_id

    add_index :audits, [:association_id, :association_type], :name => 'association_index'
  end
end

Version data entries

42 entries across 38 versions & 7 rubygems

Version Path
notifiably_audited-activerecord-1.0.0 lib/generators/notifiably_audited/templates/rename_association_to_associated.rb
notifiably_audited-activerecord-0.1.15 lib/generators/notifiably_audited/templates/rename_association_to_associated.rb
notifiably_audited-activerecord-0.1.14 lib/generators/notifiably_audited/templates/rename_association_to_associated.rb
notifiably_audited-activerecord-0.1.12 lib/generators/notifiably_audited/templates/rename_association_to_associated.rb
notifiably_audited-activerecord-0.1.11 lib/generators/notifiably_audited/templates/rename_association_to_associated.rb
notifiably_audited-activerecord-0.0.7 lib/generators/audited/templates/rename_association_to_associated.rb
notifiably_audited-0.0.6 lib/generators/audited/templates/rename_association_to_associated.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/audited-activerecord-3.0.0/lib/generators/audited/templates/rename_association_to_associated.rb
audited-activerecord-3.0.0 lib/generators/audited/templates/rename_association_to_associated.rb
audited-activerecord-3.0.0.rc2 lib/generators/audited/templates/rename_association_to_associated.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/audited-activerecord-3.0.0.rc1/lib/generators/audited/templates/rename_association_to_associated.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/acts_as_audited-2.1.0/lib/generators/acts_as_audited/templates/rename_association_to_associated.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/acts_as_audited-2.1.0/lib/generators/acts_as_audited/templates/rename_association_to_associated.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/audited-activerecord-3.0.0.rc1/lib/generators/audited/templates/rename_association_to_associated.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/audited-activerecord-3.0.0.rc1/lib/generators/audited/templates/rename_association_to_associated.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/acts_as_audited-2.1.0/lib/generators/acts_as_audited/templates/rename_association_to_associated.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/audited-activerecord-3.0.0.rc1/lib/generators/audited/templates/rename_association_to_associated.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/acts_as_audited-2.1.0/lib/generators/acts_as_audited/templates/rename_association_to_associated.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/acts_as_audited-2.1.0/lib/generators/acts_as_audited/templates/rename_association_to_associated.rb
audited-activerecord-3.0.0.rc1 lib/generators/audited/templates/rename_association_to_associated.rb