diff --git a/lib/radiator/outline/node.ex b/lib/radiator/outline/node.ex index 5f716919..a078b009 100644 --- a/lib/radiator/outline/node.ex +++ b/lib/radiator/outline/node.ex @@ -5,6 +5,7 @@ defmodule Radiator.Outline.Node do """ use Ecto.Schema import Ecto.Changeset + alias Radiator.Podcast.Episode @derive {Jason.Encoder, only: [:uuid, :content, :creator_id, :parent_id, :prev_id]} @@ -15,11 +16,14 @@ defmodule Radiator.Outline.Node do field :parent_id, Ecto.UUID field :prev_id, Ecto.UUID + belongs_to :episode, Episode + timestamps(type: :utc_datetime) end @required_fields [ - :content + :content, + :episode_id ] @optional_fields [ diff --git a/priv/repo/migrations/20231216182723_add_outline_reference_to_episode.exs b/priv/repo/migrations/20231216182723_add_outline_reference_to_episode.exs new file mode 100644 index 00000000..590b27e8 --- /dev/null +++ b/priv/repo/migrations/20231216182723_add_outline_reference_to_episode.exs @@ -0,0 +1,9 @@ +defmodule Radiator.Repo.Migrations.AddOutlineReferenceToEpisode do + use Ecto.Migration + + def change do + alter table(:outline_nodes) do + add :episode_id, references(:episodes, on_delete: :nothing) + end + end +end