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/mix/tasks/clean_clickhouse.ex

16 lines
361 B
Elixir

defmodule Mix.Tasks.CleanClickhouse do
use Mix.Task
alias Plausible.IngestRepo
def run(_) do
%{rows: rows} = IngestRepo.query!("show tables")
tables = Enum.map(rows, fn [table] -> table end)
to_truncate = tables -- ["schema_migrations"]
Enum.each(to_truncate, fn table ->
IngestRepo.query!("truncate #{table}")
end)
end
end