Commit d1eea29c authored by Antonis Kalou's avatar Antonis Kalou

Add missing fields in claim migration

parent b80770c5
......@@ -66,7 +66,7 @@ defmodule ValueFlows.Claim do
# preload
provider: provider,
receiver: receiver,
creator: creator.id
creator: creator
)
|> common_changeset()
end
......
......@@ -14,6 +14,8 @@ defmodule ValueFlows.Claim.Claims do
def create(%User{} = creator, %{id: _} = provider, %{id: _} = receiver, %{} = attrs) do
Repo.transact_with(fn ->
attrs = prepare_attrs(attrs)
with {:ok, provider_ptr} <- Pointers.one(id: provider.id),
{:ok, receiver_ptr} <- Pointers.one(id: receiver.id) do
Repo.insert(Claim.create_changeset(creator, provider_ptr, receiver_ptr, attrs))
......@@ -21,11 +23,16 @@ defmodule ValueFlows.Claim.Claims do
end)
end
def update(%Claim{} = claim, %{} = attrs) do
def update(%Claim{} = claim, %{} = _attrs) do
{:ok, claim}
end
def soft_delete(%Claim{} = claim) do
{:ok, claim}
end
def prepare_attrs(attrs) do
attrs
|> CommonsPub.Common.maybe_put(:action_id, Map.get(attrs, :action))
end
end
......@@ -13,8 +13,10 @@ defmodule ValueFlows.Claim.Migrations do
add(:agreed_in, :string)
add(:action_id, :string)
add(:finished, :boolean)
add(:created, :timestamptz)
add(:due, :timestamptz)
add(:resource_classified_as, {:array, :string})
add(:provider_id, weak_pointer(), null: true)
add(:receiver_id, weak_pointer(), null: true)
......
# SPDX-License-Identifier: AGPL-3.0-only
defmodule CommonsPub.Common do
alias CommonsPub.Repo
def is_ulid(str) when is_binary(str) do
with :error <- Ecto.ULID.dump(str) do
false
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment