diff --git a/lib/putzplan/tasks/completed_task.ex b/lib/putzplan/tasks/completed_task.ex index 9d16520..980853f 100644 --- a/lib/putzplan/tasks/completed_task.ex +++ b/lib/putzplan/tasks/completed_task.ex @@ -11,6 +11,14 @@ defmodule Putzplan.Tasks.CompletedTask do attribute :completion, :date do allow_nil? false end + + attribute :user_id, :uuid do + allow_nil? false + end + + attribute :task_id, :uuid do + allow_nil? false + end end relationships do diff --git a/lib/putzplan/tasks/task.ex b/lib/putzplan/tasks/task.ex index aed1bb8..1e647db 100644 --- a/lib/putzplan/tasks/task.ex +++ b/lib/putzplan/tasks/task.ex @@ -19,6 +19,10 @@ defmodule Putzplan.Tasks.Task do repo Putzplan.Repo end + relationships do + has_many :completed_tasks, Putzplan.Tasks.CompletedTask + end + # Attributes are the simple pieces of data that exist on your resource attributes do # Add an autogenerated UUID primary key called `:id`. diff --git a/priv/repo/migrations/20250405121515_add_completed_tasks.exs b/priv/repo/migrations/20250405121515_add_completed_tasks.exs new file mode 100644 index 0000000..d5fb261 --- /dev/null +++ b/priv/repo/migrations/20250405121515_add_completed_tasks.exs @@ -0,0 +1,13 @@ +defmodule Putzplan.Repo.Migrations.AddCompletedTasks do + use Ecto.Migration + + def change do + create table(:completed_tasks, primary_key: false) do + add :id, :uuid, primary_key: true, null: false + add :completion, :date, null: false + + add :user_id, references(:users), null: false + add :task_id, references(:tasks), null: false + end + end +end