diff --git a/db/migrate/20210117210100_add_index_on_polls.rb b/db/migrate/20210117210100_add_index_on_polls.rb new file mode 100644 index 00000000..e1343ecb --- /dev/null +++ b/db/migrate/20210117210100_add_index_on_polls.rb @@ -0,0 +1,7 @@ +class AddIndexOnPolls < ActiveRecord::Migration[5.2] + disable_ddl_transaction! + + def change + add_index :polls, [:id, :lock_version], algorithm: :concurrently + end +end diff --git a/db/schema.rb b/db/schema.rb index aa3b3f4c..d5d48b48 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: 2021_01_17_120100) do +ActiveRecord::Schema.define(version: 2021_01_17_210100) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" @@ -571,6 +571,7 @@ ActiveRecord::Schema.define(version: 2021_01_17_120100) do t.datetime "updated_at", null: false t.integer "lock_version", default: 0, null: false t.index ["account_id"], name: "index_polls_on_account_id" + t.index ["id", "lock_version"], name: "index_polls_on_id_and_lock_version" t.index ["status_id"], name: "index_polls_on_status_id" end