mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
copy subscriptions on merge instead of moving
This commit is contained in:
parent
a079eac912
commit
ea0c9a8650
1 changed files with 9 additions and 3 deletions
|
@ -731,9 +731,15 @@ defmodule Philomena.Images do
|
|||
end
|
||||
|
||||
def migrate_subscriptions(source, target) do
|
||||
Subscription
|
||||
|> where(image_id: ^source.id)
|
||||
|> Repo.update_all(set: [image_id: target.id])
|
||||
subscriptions =
|
||||
Subscription
|
||||
|> where(image_id: ^source.id)
|
||||
|> select([s], %{image_id: type(^target.id, :integer), user_id: s.user_id})
|
||||
|> Repo.all()
|
||||
|
||||
{count, nil} = Repo.insert_all(Subscription, subscriptions, on_conflict: :nothing)
|
||||
|
||||
{:ok, count}
|
||||
end
|
||||
|
||||
def clear_notification(_image, nil), do: nil
|
||||
|
|
Loading…
Reference in a new issue