fix: add migration for completed tasks
This commit is contained in:
parent
00d15dfd47
commit
d0dd3d81dd
3 changed files with 25 additions and 0 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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`.
|
||||||
|
|
|
||||||
13
priv/repo/migrations/20250405121515_add_completed_tasks.exs
Normal file
13
priv/repo/migrations/20250405121515_add_completed_tasks.exs
Normal 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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue