Sha256: 6a978fc8972da801b57acf90c467b1dccd41a9eb53fd0d878d563bcfca1a25f2

Contents?: true

Size: 852 Bytes

Versions: 9

Compression:

Stored size: 852 Bytes

Contents

class <%= migration_class_name %> < <%= migration_parent %>
  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

9 entries across 9 versions & 1 rubygems

Version Path
audited-4.10.0 lib/generators/audited/templates/rename_association_to_associated.rb
audited-4.9.0 lib/generators/audited/templates/rename_association_to_associated.rb
audited-4.8.0 lib/generators/audited/templates/rename_association_to_associated.rb
audited-4.7.1 lib/generators/audited/templates/rename_association_to_associated.rb
audited-4.7.0 lib/generators/audited/templates/rename_association_to_associated.rb
audited-4.6.0 lib/generators/audited/templates/rename_association_to_associated.rb
audited-4.5.0 lib/generators/audited/templates/rename_association_to_associated.rb
audited-4.4.1 lib/generators/audited/templates/rename_association_to_associated.rb
audited-4.4.0 lib/generators/audited/templates/rename_association_to_associated.rb