You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
analytics/lib/plausible/migration_utils.ex

17 lines
433 B
Elixir

defmodule Plausible.MigrationUtils do
@moduledoc """
Base module for to use in Clickhouse migrations
"""
def on_cluster_statement(table) do
if(clustered_table?(table), do: "ON CLUSTER '{cluster}'", else: "")
end
def clustered_table?(table) do
case Plausible.IngestRepo.query("SELECT 1 FROM system.replicas WHERE table = '#{table}'") do
{:ok, %{rows: []}} -> false
{:ok, _} -> true
end
end
end