Sha256: ee45f68b6693fb5a6d60544c11b846500391783b2205e4fa21b1799ef6d7bb8f

Contents?: true

Size: 883 Bytes

Versions: 25

Compression:

Stored size: 883 Bytes

Contents

# frozen_string_literal: true

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

25 entries across 25 versions & 2 rubygems

Version Path
audited-5.8.0 lib/generators/audited/templates/rename_association_to_associated.rb
audited-5.7.0 lib/generators/audited/templates/rename_association_to_associated.rb
audited-5.6.0 lib/generators/audited/templates/rename_association_to_associated.rb
audited-5.5.1.pre lib/generators/audited/templates/rename_association_to_associated.rb
audited-5.5.0 lib/generators/audited/templates/rename_association_to_associated.rb
audited-5.4.3 lib/generators/audited/templates/rename_association_to_associated.rb
audited-5.4.2 lib/generators/audited/templates/rename_association_to_associated.rb
audited-5.4.1 lib/generators/audited/templates/rename_association_to_associated.rb
audited-5.4.0 lib/generators/audited/templates/rename_association_to_associated.rb
audited-5.3.3 lib/generators/audited/templates/rename_association_to_associated.rb
audited-5.3.2 lib/generators/audited/templates/rename_association_to_associated.rb
audited-5.3.1 lib/generators/audited/templates/rename_association_to_associated.rb
audited-5.3.0 lib/generators/audited/templates/rename_association_to_associated.rb
audited-5.2.0 lib/generators/audited/templates/rename_association_to_associated.rb
audited-5.1.0 lib/generators/audited/templates/rename_association_to_associated.rb
velocity_audited-6.0.4 lib/generators/audited/templates/rename_association_to_associated.rb
velocity_audited-6.0.3 lib/generators/audited/templates/rename_association_to_associated.rb
velocity_audited-6.0.1 lib/generators/audited/templates/rename_association_to_associated.rb
velocity_audited-5.1.6 lib/generators/audited/templates/rename_association_to_associated.rb
velocity_audited-5.1.5 lib/generators/audited/templates/rename_association_to_associated.rb