Split funnel schema modules
parent
adbfef20b0
commit
5cf268b5b7
@ -0,0 +1,22 @@
|
||||
defmodule Plausible.Funnel.Step do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
@type t() :: %__MODULE__{}
|
||||
schema "funnel_steps" do
|
||||
field :step_order, :integer
|
||||
belongs_to :funnel, Plausible.Funnel
|
||||
belongs_to :goal, Plausible.Goal
|
||||
timestamps()
|
||||
end
|
||||
|
||||
def changeset(step, attrs \\ %{}) do
|
||||
step
|
||||
|> cast(attrs, [:goal_id])
|
||||
|> cast_assoc(:goal)
|
||||
|> validate_required([:goal_id])
|
||||
|> unique_constraint(:goal,
|
||||
name: :funnel_steps_goal_id_funnel_id_index
|
||||
)
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue