Skip to content

Commit

Permalink
fix: recreate entity index using btree (#1238)
Browse files Browse the repository at this point in the history
* fix: recreate entity index using btree

* create index concurrently

* bump version

* use ex instead of exs

---------

Co-authored-by: Filipe Cabaço <[email protected]>
  • Loading branch information
w3b6x9 and filipecabaco authored Dec 1, 2024
1 parent 5deb4f3 commit 93fb070
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/realtime/tenants/migrations.ex
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ defmodule Realtime.Tenants.Migrations do
UuidAutoGeneration,
MessagesPartitioning,
MessagesUsingUuid,
FixSendFunction
FixSendFunction,
RecreateEntityIndexUsingBtree
}

@migrations [
Expand Down Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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("""
do $$
begin
create index concurrently if not exists ix_realtime_subscription_entity on realtime.subscription using btree (entity);
exception
when others then
create index if not exists ix_realtime_subscription_entity on realtime.subscription using btree (entity);
end$$;
""")
end
end
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Realtime.MixProject do
def project do
[
app: :realtime,
version: "2.33.60",
version: "2.33.61",
elixir: "~> 1.17.3",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down

0 comments on commit 93fb070

Please sign in to comment.