Add index to sort by position

This commit is contained in:
Jorge Manrubia
2025-10-29 17:13:31 +01:00
parent a86db74cc4
commit a98a0eb3fc
3 changed files with 25 additions and 2 deletions
@@ -0,0 +1,5 @@
class AddIndexOnCollectionAndPositionToColumns < ActiveRecord::Migration[8.2]
def change
add_index :columns, [ :collection_id, :position ]
end
end
Generated
+2 -1
View File
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.2].define(version: 2025_10_29_142418) do
ActiveRecord::Schema[8.2].define(version: 2025_10_29_161222) do
create_table "accesses", force: :cascade do |t|
t.datetime "accessed_at"
t.integer "collection_id", null: false
@@ -193,6 +193,7 @@ ActiveRecord::Schema[8.2].define(version: 2025_10_29_142418) do
t.string "name", null: false
t.integer "position", default: 0, null: false
t.datetime "updated_at", null: false
t.index ["collection_id", "position"], name: "index_columns_on_collection_id_and_position"
t.index ["collection_id"], name: "index_columns_on_collection_id"
end
+18 -1
View File
@@ -1929,6 +1929,23 @@ indexes:
nulls_not_distinct:
comment:
valid: true
- !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition
table: columns
name: index_columns_on_collection_id_and_position
unique: false
columns:
- collection_id
- position
lengths: {}
orders: {}
opclasses: {}
where:
type:
using:
include:
nulls_not_distinct:
comment:
valid: true
comments:
- !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition
table: comments
@@ -2828,4 +2845,4 @@ indexes:
nulls_not_distinct:
comment:
valid: true
version: 20251029142418
version: 20251029161222