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
Fix community editon migrations (#5307)
hq1023c7ac2c04a
diff --git a/priv/ingest_repo/migrations/20230509124919_clean_up_old_tables_after_v2_migration.exs b/priv/ingest_repo/migrations/20230509124919_clean_up_old_tables_after_v2_migration.exsindex 9102767bd9..7b2456030e 100644--- a/priv/ingest_repo/migrations/20230509124919_clean_up_old_tables_after_v2_migration.exs+++ b/priv/ingest_repo/migrations/20230509124919_clean_up_old_tables_after_v2_migration.exs@@ -1,10 +1,10 @@defmodule Plausible.IngestRepo.Migrations.CleanUpOldTablesAfterV2Migration douse Ecto.Migration- def change do- selfhost? = Application.fetch_env!(:plausible, :is_selfhost)+ import Plausible.MigrationUtils- unless selfhost? do+ def change do+ unless community_edition?() dodrop_if_exists table(:events)drop_if_exists table(:sessions)enddiff --git a/priv/repo/migrations/20231121131602_create_plans_table.exs b/priv/repo/migrations/20231121131602_create_plans_table.exsindex 0ad209e737..fc3cbc58c5 100644--- a/priv/repo/migrations/20231121131602_create_plans_table.exs+++ b/priv/repo/migrations/20231121131602_create_plans_table.exs@@ -1,8 +1,10 @@defmodule Plausible.Repo.Migrations.CreatePlansTable douse Ecto.Migration+ import Plausible.MigrationUtils+def change do- if !Application.get_env(:plausible, :is_selfhost) do+ if enterprise_edition?() docreate table(:plans) doadd :generation, :integer, null: falseadd :kind, :string, null: falsediff --git a/priv/repo/migrations/20231208125624_add_data_retention_in_years_to_plans.exs b/priv/repo/migrations/20231208125624_add_data_retention_in_years_to_plans.exsindex 6c1188be36..feb0c6fee1 100644--- a/priv/repo/migrations/20231208125624_add_data_retention_in_years_to_plans.exs+++ b/priv/repo/migrations/20231208125624_add_data_retention_in_years_to_plans.exs@@ -1,8 +1,10 @@defmodule Plausible.Repo.Migrations.AddDataRetentionInYearsToPlans douse Ecto.Migration+ import Plausible.MigrationUtils+def change do- if !Application.get_env(:plausible, :is_selfhost) do+ if enterprise_edition?() doalter table(:plans) doadd :data_retention_in_years, :integer, null: trueenddiff --git a/priv/repo/migrations/20250318131615_site_legacy_time_on_page_cutoff.exs b/priv/repo/migrations/20250318131615_site_legacy_time_on_page_cutoff.exsindex dd5e1e4aff..31c245171c 100644--- a/priv/repo/migrations/20250318131615_site_legacy_time_on_page_cutoff.exs+++ b/priv/repo/migrations/20250318131615_site_legacy_time_on_page_cutoff.exs@@ -2,6 +2,8 @@ defmodule Plausible.Repo.Migrations.SiteLegacyTimeOnPageCutoff douse Ecto.Migrationuse Plausible+ import Plausible.MigrationUtils+def change doalter table(:sites) do# New sites will have new time-on-page enabled by default.@@ -9,11 +11,13 @@ defmodule Plausible.Repo.Migrations.SiteLegacyTimeOnPageCutoff dodefault: fragment("to_date('1970-01-01', 'YYYY-MM-DD')")end- if Application.get_env(:plausible, :is_selfhost) do+ 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 = ?", [Date.utc_today()])+ repo().query!("UPDATE sites SET legacy_time_on_page_cutoff = $1::date", [+ Date.utc_today()+ ])end,&pass/0)diff --git a/priv/repo/migrations/20250403093826_backfill_teams_hourly_api_request_limit.exs b/priv/repo/migrations/20250403093829_backfill_teams_hourly_api_request_limit.exssimilarity index 100%rename from priv/repo/migrations/20250403093826_backfill_teams_hourly_api_request_limit.exsrename to priv/repo/migrations/20250403093829_backfill_teams_hourly_api_request_limit.exsdiff --git a/test/plausible/release_test.exs b/test/plausible/release_test.exsindex a39e0d6e1c..4c4d59f988 100644--- a/test/plausible/release_test.exs+++ b/test/plausible/release_test.exs@@ -30,6 +30,7 @@ defmodule Plausible.ReleaseTest doendend+ @tag :ee_onlytest "dump_plans/0 inserts plans" dostdout =capture_io(fn ->