diff --git a/db/migrate/20240318171656_add_component_device_sensor_index.rb b/db/migrate/20240318171656_add_component_device_sensor_index.rb new file mode 100644 index 00000000..e5b74064 --- /dev/null +++ b/db/migrate/20240318171656_add_component_device_sensor_index.rb @@ -0,0 +1,6 @@ +class AddComponentDeviceSensorIndex < ActiveRecord::Migration[6.1] + def change + remove_index :components, [:sensor_id] + add_index :components, [:device_id, :sensor_id] + end +end diff --git a/db/schema.rb b/db/schema.rb index 537841c5..2c934353 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_03_18_110256) do +ActiveRecord::Schema.define(version: 2024_03_18_171656) do # These are extensions that must be enabled in order to support this database enable_extension "adminpack" @@ -66,7 +66,7 @@ t.string "key" t.integer "bus", default: 1, null: false t.datetime "last_reading_at" - t.index ["sensor_id"], name: "index_components_on_sensor_id" + t.index ["device_id", "sensor_id"], name: "index_components_on_device_id_and_sensor_id" end create_table "devices", id: :serial, force: :cascade do |t|