analytics/priv/repo/migrations/20200130123049_add_site_id_to_events.exs
Uku Taht 7dbbc8ba22
Configurable site id (#30)
* Use site id instead of hostname for events

* Use site id in domain status check

* Revert change to tracking module

* Catch more places where link generation needed updating

* Rename site_id to domain

* Drop hostname index from events
2020-02-04 15:44:13 +02:00

38 lines
704 B
Elixir

defmodule Plausible.Repo.Migrations.AddSiteIdToEvents do
use Ecto.Migration
def up do
alter table(:events) do
add :site_id, :text
end
alter table(:sessions) do
add :site_id, :text
end
execute "UPDATE events set site_id=hostname"
execute "UPDATE sessions set site_id=hostname"
alter table(:events) do
modify :site_id, :text, null: false
end
alter table(:sessions) do
modify :site_id, :text, null: false
end
create index(:events, :site_id)
create index(:sessions, :site_id)
end
def down do
alter table(:events) do
remove :site_id
end
alter table(:sessions) do
remove :site_id
end
end
end