Skip to content

Commit

Permalink
fix: add in missing publication tables (#2132)
Browse files Browse the repository at this point in the history
* chore: fix flaky schema check

* Revert "fix: reduce exit trapping and error logging on supervision tree termination"

This reverts commit e2fb447.

* chore: resolve flaky tests, remove unnecessary exit trapping

* fix: add in missing publication tables

* fix: recreate missing publication tables

* fix: don't drop anything on down

* chore: formatting

* fix: don't allow publication tables to change between migrations

* fix: config reference
  • Loading branch information
Ziinc authored Jul 29, 2024
1 parent 52bd20b commit 7ae2ae1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 15 deletions.
11 changes: 1 addition & 10 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,7 @@ config :scrivener_html,

config :logflare, Logflare.ContextCache.CacheBuster,
replication_slot: :temporary,
publications: ["logflare_pub"],
# remember to add an ALTER PUBLICATION ... migration when changing published tables!
publication_tables: [
"billing_accounts",
"plans",
"rules",
"source_schemas",
"sources",
"users"
]
publications: ["logflare_pub"]

config :open_api_spex, :cache_adapter, OpenApiSpex.Plug.PersistentTermCache

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ defmodule Logflare.Repo.Migrations.SubscribeToPostgres do
@slot Application.get_env(:logflare, Logflare.ContextCache.CacheBuster)[:replication_slot]
@env Application.get_env(:logflare, :env)
@publications Application.get_env(:logflare, Logflare.ContextCache.CacheBuster)[:publications]
@publication_tables Application.get_env(:logflare, Logflare.ContextCache.CacheBuster)[:publication_tables]
@publication_tables [
"billing_accounts",
"plans",
"rules",
"source_schemas",
"sources",
"users"
]

def up do
if @env in [:dev, :test] do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
defmodule Logflare.Repo.Migrations.RecreatePublicationForTables do
use Ecto.Migration
use Ecto.Migration

@publications Application.get_env(:logflare, Logflare.ContextCache.CacheBuster)[:publications]
@publication_tables [
"billing_accounts",
"plans",
"rules",
"source_schemas",
"sources",
"users",
"backends",
"team_users"
]

def up do
for p <- @publications, do: execute("DROP PUBLICATION #{p};")
for p <- @publications do
tables = Enum.join(@publication_tables, ", ")
execute("CREATE PUBLICATION #{p} FOR TABLE #{tables};")
end
end

def down do
:noop
end
end
5 changes: 1 addition & 4 deletions test/logflare/backends_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,7 @@ defmodule Logflare.BackendsTest do
source
)

TestUtils.retry_assert(fn ->
assert_receive ^ref, 2_000
end)

assert_receive ^ref, 2_000
:timer.sleep(1000)
end
end
Expand Down

0 comments on commit 7ae2ae1

Please sign in to comment.