1 defmodule Pleroma.Repo.Migrations.UpdateMarkers do
14 defp update_markers do
15 now = NaiveDateTime.utc_now()
18 from(q in "notifications",
20 timeline: "notifications",
23 type(fragment("MAX( CASE WHEN seen = true THEN id ELSE null END )"), :string)
28 |> Enum.map(fn attrs ->
30 |> Map.put_new(:inserted_at, now)
31 |> Map.put_new(:updated_at, now)
34 Repo.insert_all("markers", markers_attrs,
35 on_conflict: {:replace, [:last_read_id, :unread_count]},
36 conflict_target: [:user_id, :timeline]