fix: add migration for completed tasks

This commit is contained in:
Moritz Böhme 2025-04-05 14:19:12 +02:00
parent 00d15dfd47
commit d0dd3d81dd
3 changed files with 25 additions and 0 deletions

View file

@ -11,6 +11,14 @@ defmodule Putzplan.Tasks.CompletedTask do
attribute :completion, :date do attribute :completion, :date do
allow_nil? false allow_nil? false
end end
attribute :user_id, :uuid do
allow_nil? false
end
attribute :task_id, :uuid do
allow_nil? false
end
end end
relationships do relationships do

View file

@ -19,6 +19,10 @@ defmodule Putzplan.Tasks.Task do
repo Putzplan.Repo repo Putzplan.Repo
end end
relationships do
has_many :completed_tasks, Putzplan.Tasks.CompletedTask
end
# Attributes are the simple pieces of data that exist on your resource # Attributes are the simple pieces of data that exist on your resource
attributes do attributes do
# Add an autogenerated UUID primary key called `:id`. # Add an autogenerated UUID primary key called `:id`.

View file

@ -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