From a98a0eb3fcd762a3bfe5d18e4f0e93eb9ab61c72 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Wed, 29 Oct 2025 17:13:31 +0100 Subject: [PATCH] Add index to sort by position --- ...x_on_collection_and_position_to_columns.rb | 5 +++++ db/schema.rb | 3 ++- db/schema_cache.yml | 19 ++++++++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20251029161222_add_index_on_collection_and_position_to_columns.rb diff --git a/db/migrate/20251029161222_add_index_on_collection_and_position_to_columns.rb b/db/migrate/20251029161222_add_index_on_collection_and_position_to_columns.rb new file mode 100644 index 000000000..1fa34f737 --- /dev/null +++ b/db/migrate/20251029161222_add_index_on_collection_and_position_to_columns.rb @@ -0,0 +1,5 @@ +class AddIndexOnCollectionAndPositionToColumns < ActiveRecord::Migration[8.2] + def change + add_index :columns, [ :collection_id, :position ] + end +end diff --git a/db/schema.rb b/db/schema.rb index cef4d628e..ede583448 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[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 diff --git a/db/schema_cache.yml b/db/schema_cache.yml index ad614480d..4ca90d0bd 100644 --- a/db/schema_cache.yml +++ b/db/schema_cache.yml @@ -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