Merge pull request #12884 from mkllnk/oc-index

Add database index to order cycle dates
This commit is contained in:
Gaetan Craig-Riou
2024-10-02 16:01:50 +10:00
committed by GitHub
2 changed files with 15 additions and 1 deletions

View File

@@ -0,0 +1,12 @@
# frozen_string_literal: true
# We use these fields a lot to find open order cycles.
# Adding indexes seems obvious but I couldn't observe any performance gain.
# I also couldn't observe any harm. So adding these indexes will avoid any
# further investigation in the future. It's done.
class AddIndexOnOrderCyclesOrdersOpenAtAndOrdersCloseAt < ActiveRecord::Migration[7.0]
def change
add_index :order_cycles, :orders_open_at
add_index :order_cycles, :orders_close_at
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2024_08_28_203544) do
ActiveRecord::Schema[7.0].define(version: 2024_10_02_014059) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
enable_extension "plpgsql"
@@ -338,6 +338,8 @@ ActiveRecord::Schema[7.0].define(version: 2024_08_28_203544) do
t.boolean "automatic_notifications", default: false
t.boolean "mails_sent", default: false
t.datetime "opened_at", precision: nil
t.index ["orders_close_at"], name: "index_order_cycles_on_orders_close_at"
t.index ["orders_open_at"], name: "index_order_cycles_on_orders_open_at"
end
create_table "order_cycles_distributor_payment_methods", id: false, force: :cascade do |t|