From 85d2f3143b1aed2aa821415f0ed0a68c8830f4ef Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Sat, 20 Mar 2021 11:09:53 +0000 Subject: [PATCH] Improve indexes on adjustments adjustable and originator associations --- ...210320003951_update_adjustments_indexes.rb | 8 ++++++++ db/schema.rb | 19 ++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 db/migrate/20210320003951_update_adjustments_indexes.rb diff --git a/db/migrate/20210320003951_update_adjustments_indexes.rb b/db/migrate/20210320003951_update_adjustments_indexes.rb new file mode 100644 index 0000000000..4828b48399 --- /dev/null +++ b/db/migrate/20210320003951_update_adjustments_indexes.rb @@ -0,0 +1,8 @@ +class UpdateAdjustmentsIndexes < ActiveRecord::Migration[5.0] + def change + remove_index :spree_adjustments, :adjustable_id + + add_index :spree_adjustments, [:adjustable_type, :adjustable_id] + add_index :spree_adjustments, [:originator_type, :originator_id] + end +end diff --git a/db/schema.rb b/db/schema.rb index ddd564122b..5321045034 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: 20210315163900) do +ActiveRecord::Schema.define(version: 20210320003951) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -372,8 +372,9 @@ ActiveRecord::Schema.define(version: 20210315163900) do t.string "state", limit: 255 t.integer "order_id" t.boolean "included", default: false - t.index ["adjustable_id"], name: "index_adjustments_on_order_id", using: :btree + t.index ["adjustable_type", "adjustable_id"], name: "index_spree_adjustments_on_adjustable_type_and_adjustable_id", using: :btree t.index ["order_id"], name: "index_spree_adjustments_on_order_id", using: :btree + t.index ["originator_type", "originator_id"], name: "index_spree_adjustments_on_originator_type_and_originator_id", using: :btree end create_table "spree_assets", force: :cascade do |t| @@ -468,14 +469,14 @@ ActiveRecord::Schema.define(version: 20210315163900) do create_table "spree_line_items", force: :cascade do |t| t.integer "order_id" t.integer "variant_id" - t.integer "quantity", null: false - t.decimal "price", precision: 10, scale: 2, null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.integer "quantity", null: false + t.decimal "price", precision: 10, scale: 2, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.integer "max_quantity" - t.string "currency", limit: 255 - t.decimal "distribution_fee", precision: 10, scale: 2 - t.decimal "final_weight_volume", precision: 10, scale: 2 + t.string "currency", limit: 255 + t.decimal "distribution_fee", precision: 10, scale: 2 + t.decimal "final_weight_volume", precision: 10, scale: 2 t.integer "tax_category_id" t.index ["order_id"], name: "index_line_items_on_order_id", using: :btree t.index ["variant_id"], name: "index_line_items_on_variant_id", using: :btree