Skip to content

fix: execute migration to set index_bridging to disabled #1379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/realtime/tenants/migrations.ex
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ defmodule Realtime.Tenants.Migrations do
RealtimeSubscriptionLogged,
RemoveUnusedPublications,
RealtimeSendSetsTopicConfig,
SubscriptionIndexBridgingDisabled
SubscriptionIndexBridgingDisabled,
RunSubscriptionIndexBridgingDisabled
}

@migrations [
Expand Down Expand Up @@ -139,7 +140,8 @@ defmodule Realtime.Tenants.Migrations do
{20_250_110_162_412, RealtimeSubscriptionLogged},
{20_250_123_174_212, RemoveUnusedPublications},
{20_250_128_220_012, RealtimeSendSetsTopicConfig},
{20_250_506_224_012, SubscriptionIndexBridgingDisabled}
{20_250_506_224_012, SubscriptionIndexBridgingDisabled},
{20_250_523_164_012, RunSubscriptionIndexBridgingDisabled}
]

defstruct [:tenant_external_id, :settings]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
defmodule Realtime.Tenants.Migrations.RunSubscriptionIndexBridgingDisabled do
@moduledoc false
use Ecto.Migration

def change do
execute("""
alter table realtime.subscription reset (index_bridging);
""")
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.55.6",
version: "2.55.7",
elixir: "~> 1.17.3",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down
2 changes: 1 addition & 1 deletion test/realtime/messages_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ defmodule Realtime.MessagesTest do
assert :ok = Messages.delete_old_messages(conn)
{:ok, current} = Repo.all(conn, from(m in Message), Message)

assert current == to_keep
assert Enum.sort(current) == Enum.sort(to_keep)
end
end
3 changes: 2 additions & 1 deletion test/realtime/repo_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ defmodule Realtime.RepoTest do
message_1 = message_fixture(tenant)
message_2 = message_fixture(tenant)

assert {:ok, [^message_1, ^message_2] = res} = Repo.all(db_conn, Message, Message)
assert {:ok, res} = Repo.all(db_conn, Message, Message)
assert Enum.sort([message_1, message_2]) == Enum.sort(res)
assert Enum.all?(res, &(Ecto.get_meta(&1, :state) == :loaded))
end

Expand Down
11 changes: 11 additions & 0 deletions test/support/containers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ defmodule Containers do
use GenServer

@image "supabase/postgres:15.8.1.040"
# Pull image if not available
def pull do
case System.cmd("docker", ["image", "inspect", @image]) do
{_, 0} ->
:ok

_ ->
IO.puts("Pulling image #{@image}. This might take a while...")
{_, 0} = System.cmd("docker", ["pull", @image])
end
end

def start_container(), do: GenServer.call(__MODULE__, :start_container, 10_000)
def port(), do: GenServer.call(__MODULE__, :port, 10_000)
Expand Down
6 changes: 6 additions & 0 deletions test/support/containers/container.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ defmodule Containers.Container do
end

def port(pid), do: GenServer.call(pid, :port, 15_000)
def name(pid), do: GenServer.call(pid, :name, 15_000)

@impl true
def handle_call(:port, _from, state) do
{:reply, state[:port], state}
end

@impl true
def handle_call(:name, _from, state) do
{:reply, state[:name], state}
end

@impl true
def init(_args) do
{:ok, %{}, {:continue, :start_container}}
Expand Down
2 changes: 2 additions & 0 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ ExUnit.start(exclude: [:failing], max_cases: 2, capture_log: true)

max_cases = ExUnit.configuration()[:max_cases]

Containers.pull()

if System.get_env("REUSE_CONTAINERS") != "true" do
Containers.stop_containers()
Containers.stop_container("dev_tenant")
Expand Down
Loading