mirror of
https://github.com/plausible/analytics.git
synced 2024-11-30 00:58:54 +03:00
6d79ca5093
* another clickhouse adapter * don't restore stats_removal.ex * fix events main-graph error (#2746) * update ch, chto * update chto again (#2759) * Stop treating page filter as an entry_page filter (#2752) * remove dead code * stop treating page filter as entry page filter in breakdown queries * stop treating page filter as entry page filter in aggregate queries * stop treating page filter as entry page filter in timeseries queries * mix format * update changelog * break code down to smaller functions to keep credo happy * remove unused functions * make CSV export return only conversions with goal filter (#2760) * make CSV export return only conversions with goal filter * update changelog * update elixir version in mix.exs (#2742) * revert admin.ex changes (#2776) --------- Co-authored-by: ruslandoga <67764432+ruslandoga@users.noreply.github.com> Co-authored-by: ruslandoga <rusl@n-do.ga> Co-authored-by: RobertJoonas <56999674+RobertJoonas@users.noreply.github.com>
63 lines
2.1 KiB
Elixir
63 lines
2.1 KiB
Elixir
defmodule Plausible.ClickhouseRepo.Migrations.CreateEventsAndSessions do
|
|
use Ecto.Migration
|
|
|
|
def up do
|
|
create_events()
|
|
create_sessions()
|
|
end
|
|
|
|
defp create_events() do
|
|
create_if_not_exists table(:events,
|
|
primary_key: false,
|
|
engine: "MergeTree",
|
|
options:
|
|
"PARTITION BY toYYYYMM(timestamp) ORDER BY (domain, toDate(timestamp), user_id) SETTINGS index_granularity = 8192"
|
|
) do
|
|
add(:name, :string)
|
|
add(:domain, :string)
|
|
add(:user_id, :UInt64)
|
|
add(:session_id, :UInt64)
|
|
add(:hostname, :string)
|
|
add(:pathname, :string)
|
|
add(:referrer, :string)
|
|
add(:referrer_source, :string)
|
|
add(:country_code, :"LowCardinality(FixedString(2))")
|
|
add(:screen_size, :"LowCardinality(String)")
|
|
add(:operating_system, :"LowCardinality(String)")
|
|
add(:browser, :"LowCardinality(String)")
|
|
|
|
add(:timestamp, :naive_datetime)
|
|
end
|
|
end
|
|
|
|
defp create_sessions() do
|
|
create_if_not_exists table(:sessions,
|
|
primary_key: false,
|
|
engine: "CollapsingMergeTree(sign)",
|
|
options:
|
|
"PARTITION BY toYYYYMM(start) ORDER BY (domain, toDate(start), user_id, session_id) SETTINGS index_granularity = 8192"
|
|
) do
|
|
add(:session_id, :UInt64)
|
|
add(:sign, :Int8)
|
|
add(:domain, :string)
|
|
add(:user_id, :UInt64)
|
|
add(:hostname, :string)
|
|
add(:is_bounce, :UInt8)
|
|
add(:entry_page, :string)
|
|
add(:exit_page, :string)
|
|
add(:pageviews, :integer)
|
|
add(:events, :integer)
|
|
add(:duration, :UInt32)
|
|
add(:referrer, :string)
|
|
add(:referrer_source, :string)
|
|
add(:country_code, :"LowCardinality(FixedString(2))")
|
|
add(:screen_size, :"LowCardinality(String)")
|
|
add(:operating_system, :"LowCardinality(String)")
|
|
add(:browser, :"LowCardinality(String)")
|
|
|
|
add(:start, :naive_datetime)
|
|
add(:timestamp, :naive_datetime)
|
|
end
|
|
end
|
|
end
|