Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Drop null constraint on user_id from subscriptions and enterprise_plans (#4868)

hq1badc4770484c
diff --git a/priv/repo/migrations/20241126103023_make_user_id_nullable_on_subscriptions_enterprise_plans.exs b/priv/repo/migrations/20241126103023_make_user_id_nullable_on_subscriptions_enterprise_plans.exs
new file mode 100644
index 0000000000..237e68fa6d
--- /dev/null
+++ b/priv/repo/migrations/20241126103023_make_user_id_nullable_on_subscriptions_enterprise_plans.exs
@@ -0,0 +1,19 @@
+defmodule Plausible.Repo.Migrations.MakeUserIdNullableOnSubscriptionsEnterprisePlans do
+ use Ecto.Migration
+
+ def change do
+ execute """
+ alter table subscriptions alter column user_id drop not null
+ """,
+ """
+ alter table subscriptions alter column user_id set not null
+ """
+
+ execute """
+ alter table enterprise_plans alter column user_id drop not null
+ """,
+ """
+ alter table enterprise_plans alter column user_id set not null
+ """
+ end
+end