From d98c4dc3b62f4a6f0df4a45a910fe79566dd3aab Mon Sep 17 00:00:00 2001 From: Wen Bo Xie Date: Sat, 30 Nov 2024 13:54:48 -0500 Subject: [PATCH] fix: recreate entity index using btree --- lib/realtime/tenants/migrations.ex | 6 ++++-- ...30184212_recreate_entity_index_using_btree.exs | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 lib/realtime/tenants/repo/migrations/20241130184212_recreate_entity_index_using_btree.exs diff --git a/lib/realtime/tenants/migrations.ex b/lib/realtime/tenants/migrations.ex index 4a592429d..822c5e1ff 100644 --- a/lib/realtime/tenants/migrations.ex +++ b/lib/realtime/tenants/migrations.ex @@ -66,7 +66,8 @@ defmodule Realtime.Tenants.Migrations do UuidAutoGeneration, MessagesPartitioning, MessagesUsingUuid, - FixSendFunction + FixSendFunction, + RecreateEntityIndexUsingBtree } @migrations [ @@ -122,7 +123,8 @@ defmodule Realtime.Tenants.Migrations do {20_241_019_105_805, UuidAutoGeneration}, {20_241_030_150_047, MessagesPartitioning}, {20_241_108_114_728, MessagesUsingUuid}, - {20_241_121_104_152, FixSendFunction} + {20_241_121_104_152, FixSendFunction}, + {20_241_130_184_212, RecreateEntityIndexUsingBtree} ] defstruct [:tenant_external_id, :settings] diff --git a/lib/realtime/tenants/repo/migrations/20241130184212_recreate_entity_index_using_btree.exs b/lib/realtime/tenants/repo/migrations/20241130184212_recreate_entity_index_using_btree.exs new file mode 100644 index 000000000..78f51e075 --- /dev/null +++ b/lib/realtime/tenants/repo/migrations/20241130184212_recreate_entity_index_using_btree.exs @@ -0,0 +1,15 @@ +defmodule Realtime.Tenants.Migrations.RecreateEntityIndexUsingBtree do + @moduledoc false + + use Ecto.Migration + + def change do + execute( + "drop index if exists \"realtime\".\"ix_realtime_subscription_entity\"" + ) + + execute( + "create index if not exists ix_realtime_subscription_entity on realtime.subscription using btree (entity)" + ) + end +end