Skip to content

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

Migration: add funnel related tables (#3022)

hq13dce3142bfb9
diff --git a/priv/repo/migrations/20230417095029_init_funnels.exs b/priv/repo/migrations/20230417095029_init_funnels.exs
new file mode 100644
index 0000000000..f45fe6423b
--- /dev/null
+++ b/priv/repo/migrations/20230417095029_init_funnels.exs
@@ -0,0 +1,21 @@
+defmodule Plausible.Repo.Migrations.InitFunnels do
+ use Ecto.Migration
+
+ def change do
+ create table(:funnels) do
+ add :name, :string, null: false
+ add :site_id, references(:sites, on_delete: :delete_all), null: false
+ timestamps()
+ end
+
+ create table(:funnel_steps) do
+ add :goal_id, references(:goals, on_delete: :delete_all), null: false
+ add :funnel_id, references(:funnels, on_delete: :delete_all), null: false
+ add :step_order, :integer, null: false
+ timestamps()
+ end
+
+ create unique_index(:funnel_steps, [:goal_id, :funnel_id])
+ create unique_index(:funnels, [:name, :site_id])
+ end
+end