Skip to content

Commit

Permalink
Merge pull request #10 from coingaming/fix/migration-clickhouse-cloud
Browse files Browse the repository at this point in the history
Fix/migration clickhouse cloud
  • Loading branch information
karlosmid authored Aug 28, 2024
2 parents 49270c8 + 664e204 commit 10be0cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 118 deletions.
12 changes: 11 additions & 1 deletion lib/plausible/migration_utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Plausible.MigrationUtils do
"""

def on_cluster_statement(table) do
if(clustered_table?(table), do: "ON CLUSTER '{cluster}'", else: "")
if(clustered_table?(table), do: "ON CLUSTER '#{cluster_name()}'", else: "")
end

def clustered_table?(table) do
Expand All @@ -13,4 +13,14 @@ defmodule Plausible.MigrationUtils do
{:ok, _} -> true
end
end

def cluster_name do
case Plausible.IngestRepo.query(
"SELECT cluster FROM system.clusters where cluster != 'default' limit 1;"
) do
{:ok, %{rows: [[cluster]]}} -> cluster
{:ok, _} -> raise "No cluster defined."
{:error, _} -> raise "Cluster not found"
end
end
end
118 changes: 1 addition & 117 deletions priv/tracker/js/plausible.live-view.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 10be0cf

Please sign in to comment.