Skip to content

Commit

Permalink
add better component indices
Browse files Browse the repository at this point in the history
  • Loading branch information
timcowlishaw committed Mar 18, 2024
1 parent cfac531 commit 6c00ac4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 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: 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"
Expand Down Expand Up @@ -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|
Expand Down

0 comments on commit 6c00ac4

Please sign in to comment.