Sha256: 66de29a8917f5ad70429ce884533f87ac4f007f72e031c90671771618cdb9c05

Contents?: true

Size: 711 Bytes

Versions: 9

Compression:

Stored size: 711 Bytes

Contents

class AddIndexToMetadataBulkraxIdentifier < ActiveRecord::Migration[5.2]
  def up
    return unless table_exists?(:orm_resources)
    return if index_exists?(:orm_resources, "(((metadata -> 'bulkrax_identifier'::text) ->> 0))", name: 'index_on_bulkrax_identifier')

    # This creates an expression index on the first element of the bulkrax_identifier array
    add_index :orm_resources,
              "(metadata -> 'bulkrax_identifier' ->> 0)",
              name: 'index_on_bulkrax_identifier',
              where: "metadata -> 'bulkrax_identifier' IS NOT NULL"
  end

  def down
    return unless table_exists?(:orm_resources)

    remove_index :orm_resources, name: 'index_on_bulkrax_identifier'
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
bulkrax-9.0.2 db/migrate/20240307053156_add_index_to_metadata_bulkrax_identifier.rb
bulkrax-9.0.1 db/migrate/20240307053156_add_index_to_metadata_bulkrax_identifier.rb
bulkrax-9.0.0 db/migrate/20240307053156_add_index_to_metadata_bulkrax_identifier.rb
bulkrax-8.2.3 db/migrate/20240307053156_add_index_to_metadata_bulkrax_identifier.rb
bulkrax-8.2.2 db/migrate/20240307053156_add_index_to_metadata_bulkrax_identifier.rb
bulkrax-8.3.0 db/migrate/20240307053156_add_index_to_metadata_bulkrax_identifier.rb
bulkrax-8.2.1 db/migrate/20240307053156_add_index_to_metadata_bulkrax_identifier.rb
bulkrax-8.2.0 db/migrate/20240307053156_add_index_to_metadata_bulkrax_identifier.rb
bulkrax-8.1.0 db/migrate/20240307053156_add_index_to_metadata_bulkrax_identifier.rb