From c028b7fe3f8a86ad1dc3f51311274fc1911a80cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Wo=CC=88ginger?= Date: Sat, 16 Dec 2023 19:55:45 +0100 Subject: [PATCH] WIP add episode id to nodes --- lib/radiator/outline/node.ex | 6 +++++- .../20231216182723_add_outline_reference_to_episode.exs | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 priv/repo/migrations/20231216182723_add_outline_reference_to_episode.exs 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