posthog/models/person_overrides/sql.py
-- storage.
        created_at DateTime64(6, 'UTC') DEFAULT now(),
        -- the specific version of the `old_person_id` mapping. This is used to
        -- allow us to discard old mappings as new ones are added. This version
        -- will be provided by the corresponding PostgreSQL
        --`posthog_personoverrides` table
        version INT NOT NULL
    )
    -- By specifying Replacing merge tree on version, we allow ClickHouse to
    -- discard old versions of a `old_person_id` mapping. This should help keep
    -- performance in check as new versions are added. Note that given we can
    -- have partitioning by `oldest_event` which will change as we update
    -- `person_id` on old partitions.
    --
    -- We also need to ensure that the data is replicated to all replicas in the
    -- cluster, as we do not have any constraints on person_id and which shard
    -- associated events are on. To do this we use the ReplicatedReplacingMergeTree
    -- engine specifying a static `zk_path`. This will cause the Engine to
    -- consider all replicas as the same. See
    -- https://clickhouse.com/docs/en/engines/table-engines/mergetree-family/replication
    -- for details.
    ENGINE = ReplicatedReplacingMergeTree(
        '/clickhouse/tables/noshard/{CLICKHOUSE_DATABASE}.person_overrides',
        '{{replica}}-{{shard}}',
        version
    )
    -- We partition the table by the `oldest_event` column. This allows us to
    -- handle updating the events table partition by partition, progressing each
    -- override partition by partition in lockstep with the events table. Note
    -- that this means it is possible that we have a mapping from