mirror of
https://github.com/plausible/analytics.git
synced 2024-11-24 04:32:57 +03:00
26 lines
527 B
Elixir
26 lines
527 B
Elixir
|
defmodule Plausible.Repo.Migrations.AddEntryPageToSessions do
|
||
|
use Ecto.Migration
|
||
|
|
||
|
def change do
|
||
|
alter table(:sessions) do
|
||
|
add :entry_page, :text
|
||
|
end
|
||
|
|
||
|
execute """
|
||
|
UPDATE sessions SET entry_page = pathname
|
||
|
FROM events
|
||
|
WHERE events.user_id = sessions.user_id
|
||
|
AND events.name = 'pageview'
|
||
|
AND events.new_visitor
|
||
|
"""
|
||
|
|
||
|
execute """
|
||
|
DELETE FROM sessions WHERE entry_page is null
|
||
|
"""
|
||
|
|
||
|
alter table(:sessions) do
|
||
|
modify :entry_page, :text, null: false
|
||
|
end
|
||
|
end
|
||
|
end
|