Skip to content

Commit

Permalink
add unique index
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeta committed Oct 28, 2023
1 parent 990d4d6 commit c730e6a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ def change
add_index :checkins, [:item_id, :basket_id], unique: true

remove_index :checkouts, [:item_id, :basket_id]
add_index :checkouts, [:item_id, :basket_id], unique: true
add_index :checkouts, [:item_id, :basket_id, :user_id], unique: true
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddUniqueIndexToCarrierTypeHasCheckoutTypesOnCarrierTypeIdAndCheckoutTypeId < ActiveRecord::Migration[6.1]
def change
remove_index :carrier_type_has_checkout_types, :carrier_type_id
add_index :carrier_type_has_checkout_types, [:carrier_type_id, :checkout_type_id], unique: true, name: 'index_carrier_type_has_checkout_types_on_carrier_type_id'

remove_index :user_group_has_checkout_types, :user_group_id
add_index :user_group_has_checkout_types, [:user_group_id, :checkout_type_id], unique: true, name: 'index_user_group_has_checkout_types_on_user_group_id'
end
end
8 changes: 4 additions & 4 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2023_10_27_175624) do
ActiveRecord::Schema.define(version: 2023_10_28_035847) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -276,7 +276,7 @@
t.integer "position"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["carrier_type_id"], name: "index_carrier_type_has_checkout_types_on_m_form_id"
t.index ["carrier_type_id", "checkout_type_id"], name: "index_carrier_type_has_checkout_types_on_carrier_type_id", unique: true
t.index ["checkout_type_id"], name: "index_carrier_type_has_checkout_types_on_checkout_type_id"
end

Expand Down Expand Up @@ -361,7 +361,7 @@
t.bigint "library_id"
t.index ["basket_id"], name: "index_checkouts_on_basket_id"
t.index ["checkin_id"], name: "index_checkouts_on_checkin_id"
t.index ["item_id", "basket_id"], name: "index_checkouts_on_item_id_and_basket_id", unique: true
t.index ["item_id", "basket_id", "user_id"], name: "index_checkouts_on_item_id_and_basket_id_and_user_id", unique: true
t.index ["item_id"], name: "index_checkouts_on_item_id"
t.index ["librarian_id"], name: "index_checkouts_on_librarian_id"
t.index ["library_id"], name: "index_checkouts_on_library_id"
Expand Down Expand Up @@ -1715,7 +1715,7 @@
t.datetime "updated_at", precision: 6, null: false
t.integer "current_checkout_count"
t.index ["checkout_type_id"], name: "index_user_group_has_checkout_types_on_checkout_type_id"
t.index ["user_group_id"], name: "index_user_group_has_checkout_types_on_user_group_id"
t.index ["user_group_id", "checkout_type_id"], name: "index_user_group_has_checkout_types_on_user_group_id", unique: true
end

create_table "user_groups", force: :cascade do |t|
Expand Down

0 comments on commit c730e6a

Please sign in to comment.