Sha256: eaff05b0a5c047af20607f761439148625004df66213565dc2a2d7e196311a53

Contents?: true

Size: 637 Bytes

Versions: 25

Compression:

Stored size: 637 Bytes

Contents

# frozen_string_literal: true

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

25 entries across 25 versions & 2 rubygems

Version Path
velocity_audited-5.1.4 lib/generators/audited/templates/add_version_to_auditable_index.rb
velocity_audited-5.1.3 lib/generators/audited/templates/add_version_to_auditable_index.rb
audited-5.0.2 lib/generators/audited/templates/add_version_to_auditable_index.rb
audited-5.0.1 lib/generators/audited/templates/add_version_to_auditable_index.rb
audited-5.0.0 lib/generators/audited/templates/add_version_to_auditable_index.rb