1
1
mirror of https://github.com/plausible/analytics.git synced 2024-12-22 09:01:40 +03:00
analytics/priv/repo/migrations/20190523160838_add_raw_referrer.exs
2019-09-02 12:29:19 +01:00

20 lines
469 B
Elixir

defmodule Plausible.Repo.Migrations.AddRawReferrer do
use Ecto.Migration
def change do
alter table(:pageviews) do
add :raw_referrer, :text
end
flush()
execute "UPDATE pageviews set raw_referrer = referrer"
flush()
execute """
UPDATE pageviews SET referrer = split_part(split_part(regexp_replace(regexp_replace(regexp_replace(raw_referrer, '^https://', ''), '^http://', ''), '^www\.', ''), '?', 1), '#', 1)
"""
end
end