analytics/priv/repo/migrations/20230417095029_init_funnels.exs
hq1 3dce3142bf
Migration: add funnel related tables (#3022)
priv/repo/migrations/20230417095029_init_funnels.exs - restored from:

aa59adeb wip
4d039ba2 Make funnel names unique
4f3216b3 Unique steps
e55edf8e Rename funnel_goals->funnel_steps
34ceb3f5 dirty wip
2023-06-13 09:27:18 +02:00

22 lines
651 B
Elixir

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