mirror of
https://github.com/plausible/analytics.git
synced 2024-12-23 01:22:15 +03:00
Migration: add imported custom events (#4076)
* Add `imported_custom_events` to CH * remove redundant table setting * add path column --------- Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
This commit is contained in:
parent
02d4709be7
commit
c106595be0
@ -0,0 +1,41 @@
|
||||
defmodule Plausible.IngestRepo.Migrations.AddImportedCustomEvents do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
# NOTE: Using another table for determining cluster presence
|
||||
on_cluster = Plausible.MigrationUtils.on_cluster_statement("imported_pages")
|
||||
|
||||
settings =
|
||||
if Plausible.MigrationUtils.clustered_table?("imported_pages") do
|
||||
"""
|
||||
ENGINE = ReplicatedMergeTree('/clickhouse/{cluster}/tables/{shard}/{database}/imported_custom_events', '{replica}')
|
||||
ORDER BY (site_id, import_id, date, name)
|
||||
SETTINGS replicated_deduplication_window = 0, storage_policy = 'tiered'
|
||||
"""
|
||||
else
|
||||
"""
|
||||
ENGINE = MergeTree()
|
||||
ORDER BY (site_id, import_id, date, name)
|
||||
SETTINGS replicated_deduplication_window = 0
|
||||
"""
|
||||
end
|
||||
|
||||
execute """
|
||||
CREATE TABLE IF NOT EXISTS imported_custom_events #{on_cluster}
|
||||
(
|
||||
`site_id` UInt64,
|
||||
`import_id` UInt64,
|
||||
`date` Date,
|
||||
`name` String CODEC(ZSTD(3)),
|
||||
`link_url` String CODEC(ZSTD(3)),
|
||||
`path` String CODEC(ZSTD(3)),
|
||||
`visitors` UInt64,
|
||||
`events` UInt64
|
||||
)
|
||||
#{settings}
|
||||
""",
|
||||
"""
|
||||
DROP TABLE IF EXISTS imported_custom_events #{on_cluster} SYNC
|
||||
"""
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user