analytics/priv/repo/migrations/20190523160838_add_raw_referrer.exs

20 lines
469 B
Elixir
Raw Normal View History

2019-09-02 14:29:19 +03:00
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