Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
defmodule Plausible.Repo.Migrations.SiteLegacyTimeOnPageCutoff do
use Ecto.Migration
use Plausible
import Plausible.MigrationUtils
def change do
alter table(:sites) do
# New sites will have new time-on-page enabled by default.
add :legacy_time_on_page_cutoff, :date,
default: fragment("to_date('1970-01-01', 'YYYY-MM-DD')")
end
if community_edition?() do
# On self-hosted, new time-on-page will be populated during first deploy.
execute(
fn ->
repo().query!("UPDATE sites SET legacy_time_on_page_cutoff = $1::date", [
Date.utc_today()
])
end,
&pass/0
)
else
# On cloud, existing sites will not have legacy_time_on_page_cutoff set. This will be populated by a cron instead.
execute(
fn -> repo().query!("UPDATE sites SET legacy_time_on_page_cutoff = NULL") end,
&pass/0
)
end
end
defp pass(), do: nil
end