diff --git a/db/migrate/20241120203200_add_index_to_tenant_and_code.rb b/db/migrate/20241120203200_add_index_to_tenant_and_code.rb new file mode 100644 index 00000000..762663ab --- /dev/null +++ b/db/migrate/20241120203200_add_index_to_tenant_and_code.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddIndexToTenantAndCode < ActiveRecord::Migration[6.1] + def change + add_index(:rooms, [:tenant, :code], unique: true) + end +end diff --git a/db/schema.rb b/db/schema.rb index a201779c..fcbd4105 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2024_07_24_170414) do +ActiveRecord::Schema.define(version: 2024_11_20_203200) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -36,6 +36,7 @@ t.string "shared_code" t.boolean "use_shared_code" t.index ["code"], name: "index_rooms_on_code" + t.index ["tenant", "code"], name: "index_rooms_on_tenant_and_code", unique: true t.index ["tenant", "handler"], name: "index_rooms_on_tenant_and_handler", unique: true t.index ["tenant", "handler_legacy"], name: "index_rooms_on_tenant_and_handler_legacy", unique: true end