analytics/priv/ingest_repo/migrations/20211112130238_create_imported_tables.exs
Adam 6d79ca5093
Switch to new clickhouse adapter (ch/chto) (#2733)
* 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>
2023-03-21 09:55:59 +01:00

137 lines
4.4 KiB
Elixir

defmodule Plausible.ClickhouseRepo.Migrations.CreateImportedVisitors do
use Ecto.Migration
def change do
create_if_not_exists table(:imported_visitors,
primary_key: false,
engine: "MergeTree",
options: "ORDER BY (site_id, date)"
) do
add(:site_id, :UInt64)
add(:date, :date)
add(:visitors, :UInt64)
add(:pageviews, :UInt64)
add(:bounces, :UInt64)
add(:visits, :UInt64)
add(:visit_duration, :UInt64)
end
create_if_not_exists table(:imported_sources,
primary_key: false,
engine: "MergeTree",
options: "ORDER BY (site_id, date, source)"
) do
add(:site_id, :UInt64)
add(:date, :date)
add(:source, :string)
add(:utm_medium, :string)
add(:utm_campaign, :string)
add(:utm_content, :string)
add(:utm_term, :string)
add(:visitors, :UInt64)
add(:visits, :UInt64)
add(:visit_duration, :UInt64)
add(:bounces, :UInt32)
end
create_if_not_exists table(:imported_pages,
primary_key: false,
engine: "MergeTree",
options: "ORDER BY (site_id, date, hostname, page)"
) do
add(:site_id, :UInt64)
add(:date, :date)
add(:hostname, :string)
add(:page, :string)
add(:visitors, :UInt64)
add(:pageviews, :UInt64)
add(:exits, :UInt64)
add(:time_on_page, :UInt64)
end
create_if_not_exists table(:imported_entry_pages,
primary_key: false,
engine: "MergeTree",
options: "ORDER BY (site_id, date, entry_page)"
) do
add(:site_id, :UInt64)
add(:date, :date)
add(:entry_page, :string)
add(:visitors, :UInt64)
add(:entrances, :UInt64)
add(:visit_duration, :UInt64)
add(:bounces, :UInt32)
end
create_if_not_exists table(:imported_exit_pages,
primary_key: false,
engine: "MergeTree",
options: "ORDER BY (site_id, date, exit_page)"
) do
add(:site_id, :UInt64)
add(:date, :date)
add(:exit_page, :string)
add(:visitors, :UInt64)
add(:exits, :UInt64)
end
create_if_not_exists table(:imported_locations,
primary_key: false,
engine: "MergeTree",
options: "ORDER BY (site_id, date, country, region, city)"
) do
add(:site_id, :UInt64)
add(:date, :date)
add(:country, :string)
add(:region, :string)
add(:city, :UInt64)
add(:visitors, :UInt64)
add(:visits, :UInt64)
add(:visit_duration, :UInt64)
add(:bounces, :UInt32)
end
create_if_not_exists table(:imported_devices,
primary_key: false,
engine: "MergeTree",
options: "ORDER BY (site_id, date, device)"
) do
add(:site_id, :UInt64)
add(:date, :date)
add(:device, :string)
add(:visitors, :UInt64)
add(:visits, :UInt64)
add(:visit_duration, :UInt64)
add(:bounces, :UInt32)
end
create_if_not_exists table(:imported_browsers,
primary_key: false,
engine: "MergeTree",
options: "ORDER BY (site_id, date, browser)"
) do
add(:site_id, :UInt64)
add(:date, :date)
add(:browser, :string)
add(:visitors, :UInt64)
add(:visits, :UInt64)
add(:visit_duration, :UInt64)
add(:bounces, :UInt32)
end
create_if_not_exists table(:imported_operating_systems,
primary_key: false,
engine: "MergeTree",
options: "ORDER BY (site_id, date, operating_system)"
) do
add(:site_id, :UInt64)
add(:date, :date)
add(:operating_system, :string)
add(:visitors, :UInt64)
add(:visits, :UInt64)
add(:visit_duration, :UInt64)
add(:bounces, :UInt32)
end
end
end