Skip to content

Commit

Permalink
fix unique index
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeta committed Oct 28, 2023
1 parent c730e6a commit c02f70c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class AddUniqueIndexToLibrariesOnName < ActiveRecord::Migration[6.1]
def change
add_index :libraries, :name, unique: true
add_index :libraries, :isil, unique: true, where: "isil != '' AND isil IS NOT NULL"
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class AddUniqueIndexToItemsOnItemIdentifier < ActiveRecord::Migration[6.1]
def change
remove_index :items, :item_identifier
add_index :items, :item_identifier, unique: true
add_index :items, :item_identifier, unique: true, where: "item_identifier != '' AND item_identifier IS NOT NULL"
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@
t.index ["bookstore_id"], name: "index_items_on_bookstore_id"
t.index ["checkout_type_id"], name: "index_items_on_checkout_type_id"
t.index ["circulation_status_id"], name: "index_items_on_circulation_status_id"
t.index ["item_identifier"], name: "index_items_on_item_identifier", unique: true
t.index ["item_identifier"], name: "index_items_on_item_identifier", unique: true, where: "(((item_identifier)::text <> ''::text) AND (item_identifier IS NOT NULL))"
t.index ["manifestation_id"], name: "index_items_on_manifestation_id"
t.index ["required_role_id"], name: "index_items_on_required_role_id"
t.index ["shelf_id"], name: "index_items_on_shelf_id"
Expand Down Expand Up @@ -834,6 +834,7 @@
t.float "latitude"
t.float "longitude"
t.index "lower((name)::text)", name: "index_libraries_on_lower_name", unique: true
t.index ["isil"], name: "index_libraries_on_isil", unique: true, where: "(((isil)::text <> ''::text) AND (isil IS NOT NULL))"
t.index ["library_group_id"], name: "index_libraries_on_library_group_id"
t.index ["name"], name: "index_libraries_on_name", unique: true
end
Expand Down

0 comments on commit c02f70c

Please sign in to comment.