Sha256: caa8554e048a1d6f9851d45f94815953432487a4d564ece73b323196dcb61a7d

Contents?: true

Size: 606 Bytes

Versions: 3

Compression:

Stored size: 606 Bytes

Contents

class <%= migration_class_name %> < <%= migration_parent %>
  def self.up
    if index_exists?(:audits, [:auditable_type, :auditable_id], name: index_name)
      remove_index :audits, name: index_name
      add_index :audits, [:auditable_type, :auditable_id, :version], name: index_name
    end
  end

  def self.down
    if index_exists?(:audits, [:auditable_type, :auditable_id, :version], name: index_name)
      remove_index :audits, name: index_name
      add_index :audits, [:auditable_type, :auditable_id], name: index_name
    end
  end

  private

  def index_name
    'auditable_index'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
audited-4.10.0 lib/generators/audited/templates/add_version_to_auditable_index.rb
audited-4.9.0 lib/generators/audited/templates/add_version_to_auditable_index.rb
audited-4.8.0 lib/generators/audited/templates/add_version_to_auditable_index.rb