Skip to content

Commit

Permalink
chore: use alter publication
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziinc committed Dec 5, 2024
1 parent a723db9 commit 604b124
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,29 @@ defmodule Logflare.Repo.Migrations.RecreateTablesPublication do
use Ecto.Migration

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

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};")
tables = Enum.join(@new_publication_tables, ", ")
execute("ALTER PUBLICATION #{p} FOR TABLE #{tables};")
end
end

def down do
:noop
for p <- @publications do
tables = Enum.join(@prev_publication_tables, ", ")
execute("ALTER PUBLICATION #{p} FOR TABLE #{tables};")
end
end
end

0 comments on commit 604b124

Please sign in to comment.