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
Implement backfill migration for enterprise plans (#5368)
Adrian Gruntkowskia147aea0c1a6
diff --git a/priv/repo/migrations/20250429093725_backfill_enterise_plans_feautres_sites_api.exs b/priv/repo/migrations/20250429093725_backfill_enterise_plans_feautres_sites_api.exsnew file mode 100644index 0000000000..50ea27f1a6--- /dev/null+++ b/priv/repo/migrations/20250429093725_backfill_enterise_plans_feautres_sites_api.exs@@ -0,0 +1,27 @@+defmodule Plausible.Repo.Migrations.BackfillEnterisePlansFeautresSitesApi do+ use Ecto.Migration++ def change do+ execute """+ UPDATE enterprise_plans ep SET features = array_append(features, 'sites_api')+ WHERE+ 'stats_api' = ANY(features) AND+ EXISTS (+ SELECT 1 FROM team_memberships AS tm+ WHERE+ tm.team_id = ep.team_id AND+ EXISTS(+ SELECT 1 FROM api_keys ak+ WHERE+ ak.user_id = tm.user_id AND+ 'sites:provision:*' = ANY(ak.scopes)+ )+ )+ """,+ """+ UPDATE enterprise_plans SET features = array(+ SELECT unnest(features) EXCEPT SELECT unnest('{"sites_api"}'::varchar[])+ )+ """+ end+end