View Source Plausible.DataMigration.LocationsSync (Plausible v0.0.1)
ClickHouse locations data migration for storing location names in ClickHouse.
Only run when Location.version()
changes: either as a migration or in cron.
The migration:
- Truncates existing
location_data
table (if exists) - Creates new table (if needed)
- Inserts new data from Location module
- (Re-)Creates dictionary to read location data from table
- Creates ALIAS columns in
events_v2
,sessions_v2
andimported_locations
table to make reading location names easy - Updates table comment for
location_data
to indicate last version synced.
Note that the dictionary is large enough to cache the whole dataset in memory, making lookups fast.
This migration is intended to be idempotent and rerunnable - if run multiple times, it should always set things to the same result as if run once.
SQL files available at: priv/data_migrations/LocationsSync/sql
Summary
Functions
Runs a single SQL query in a file.
Valid options:
quiet
- reduces output from running the SQLparams
- List of query parameters.query_options
- passed to Repo.query
Runs multiple SQL queries from a single file.
Note that each query must be separated by semicolons.