Skip to content
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

fix: Set fixed publication name; cleanup unused publications #1279

Merged
merged 3 commits into from
Jan 23, 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 @@ -71,7 +71,8 @@ defmodule Realtime.Tenants.Migrations do
RealtimeSendHandleExceptionsRemovePartitionCreation,
RealtimeSendSetsConfig,
RealtimeSubscriptionUnlogged,
RealtimeSubscriptionLogged
RealtimeSubscriptionLogged,
RemoveUnusedPublications
filipecabaco marked this conversation as resolved.
Show resolved Hide resolved
}

@migrations [
Expand Down Expand Up @@ -133,7 +134,8 @@ defmodule Realtime.Tenants.Migrations do
{20_241_220_123_912, RealtimeSendHandleExceptionsRemovePartitionCreation},
{20_241_224_161_212, RealtimeSendSetsConfig},
{20_250_107_150_512, RealtimeSubscriptionUnlogged},
{20_250_110_162_412, RealtimeSubscriptionLogged}
{20_250_110_162_412, RealtimeSubscriptionLogged},
{20_250_123_174_212, RemoveUnusedPublications}
]

defstruct [:tenant_external_id, :settings]
Expand Down
2 changes: 1 addition & 1 deletion lib/realtime/tenants/replication_connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ defmodule Realtime.Tenants.ReplicationConnection do
end

def publication_name(%__MODULE__{table: table, schema: schema}) do
"supabase_#{schema}_#{table}_publication_#{slot_suffix()}"
"supabase_#{schema}_#{table}_publication"
end

def replication_slot_name(%__MODULE__{table: table, schema: schema}) do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
defmodule Realtime.Tenants.Migrations.RemoveUnusedPublications do
@moduledoc false
use Ecto.Migration

# Due to issues on PG Updates we can't use UNLOGGED tables due to the fact that Sequences on PG14 still need to be logged
def change do
execute("""
DO $$
DECLARE
r RECORD;
BEGIN
FOR r IN
SELECT pubname FROM pg_publication WHERE pubname LIKE 'realtime_messages%' or pubname LIKE 'supabase_realtime_messages%'
LOOP
EXECUTE 'DROP PUBLICATION IF EXISTS ' || quote_ident(r.pubname) || ';' ;
END LOOP;
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.34.6",
version: "2.34.7",
elixir: "~> 1.17.3",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down
Loading