mirror of
https://github.com/plausible/analytics.git
synced 2024-12-24 10:02:10 +03:00
6637751a5e
* Implement Numeric IDs migration * Fix typo * Mute credo for now * Improve configurability and add stop_t * Adjust to Ch/Chto only * Fix opts key for dictionary password * Add regular ecto migration with numeric ids v2 schemas (#2768) * Add regular ecto migration * Fix typo * Update priv/ingest_repo/migrations/20230320094327_create_v2_schemas.exs Co-authored-by: Vini Brasil <vini@hey.com> * Implement v2 events/sessions schema modules (#2777) * Implement v2 events/sessions schema modules * Clean up session schemas --------- Co-authored-by: Vini Brasil <vini@hey.com> * Update moduledocs --------- Co-authored-by: Vini Brasil <vini@hey.com>
46 lines
1.5 KiB
Elixir
46 lines
1.5 KiB
Elixir
CREATE TABLE sessions_v2 <%= if @cluster? do %>ON CLUSTER '{cluster}'<% end %>
|
|
(
|
|
`session_id` UInt64,
|
|
`sign` Int8,
|
|
`site_id` UInt64,
|
|
`user_id` UInt64,
|
|
`hostname` String,
|
|
`timestamp` DateTime CODEC(DoubleDelta, LZ4),
|
|
`start` DateTime CODEC(DoubleDelta, LZ4),
|
|
`is_bounce` UInt8,
|
|
`entry_page` String,
|
|
`exit_page` String,
|
|
`pageviews` Int32,
|
|
`events` Int32,
|
|
`duration` UInt32,
|
|
`referrer` String,
|
|
`referrer_source` String,
|
|
`country_code` LowCardinality(FixedString(2)),
|
|
`screen_size` LowCardinality(String),
|
|
`operating_system` LowCardinality(String),
|
|
`browser` LowCardinality(String),
|
|
`utm_medium` String,
|
|
`utm_source` String,
|
|
`utm_campaign` String,
|
|
`browser_version` LowCardinality(String),
|
|
`operating_system_version` LowCardinality(String),
|
|
`subdivision1_code` LowCardinality(String),
|
|
`subdivision2_code` LowCardinality(String),
|
|
`city_geoname_id` UInt32,
|
|
`utm_content` String,
|
|
`utm_term` String,
|
|
`transferred_from` String,
|
|
`entry_meta.key` Array(String),
|
|
`entry_meta.value` Array(String)
|
|
)
|
|
<%= if @cluster? do %>
|
|
ENGINE = ReplicatedCollapsingMergeTree('/clickhouse/{cluster}/tables/{shard}/plausible_prod/sessions_v2', '{replica}', sign)
|
|
<% else %>
|
|
ENGINE = CollapsingMergeTree(sign)
|
|
<% end %>
|
|
PARTITION BY toYYYYMM(start)
|
|
PRIMARY KEY (site_id, toDate(start), user_id, session_id)
|
|
ORDER BY (site_id, toDate(start), user_id, session_id)
|
|
SAMPLE BY user_id
|
|
<%= @table_settings %>
|