Skip to content

Commit

Permalink
fix: 🐛 migration could run on non cluster instance
Browse files Browse the repository at this point in the history
  • Loading branch information
karlosmid committed Aug 30, 2024
1 parent fc1e0d5 commit 756839e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/plausible/data_migration/versioned_sessions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ defmodule Plausible.DataMigration.VersionedSessions do
unique_suffix = Timex.now() |> Timex.format!(@suffix_format)

cluster? = Plausible.MigrationUtils.clustered_table?("sessions_v2")
cluster_name = Plausible.MigrationUtils.cluster_name()

cluster_name =
if cluster? do
Plausible.MigrationUtils.cluster_name()
else
nil
end

{:ok, %{rows: partitions}} = run_sql("list-partitions")
partitions = Enum.map(partitions, fn [part] -> part end)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ defmodule Plausible.IngestRepo.Migrations.AddImportedCustomEvents do
def change do
# NOTE: Using another table for determining cluster presence
on_cluster = Plausible.MigrationUtils.on_cluster_statement("imported_pages")
cluster_name = Plausible.MigrationUtils.cluster_name()
cluster? = Plausible.MigrationUtils.clustered_table?("imported_pages")

cluster_name =
if cluster? do
Plausible.MigrationUtils.cluster_name()
else
nil
end

settings =
if Plausible.MigrationUtils.clustered_table?("imported_pages") do
Expand Down

0 comments on commit 756839e

Please sign in to comment.