Fix Exiftool migration id
Applying works fine with a 20220220135625 version, but it won’t be rolled back in the right order. Fortunately this action is idempotent so we can just rename and reapply it with a new id. To also not break large-scale rollbacks past 2022 for anyone who already applied it with the old id, keep a stub migration.
This commit is contained in:
parent
fdeecc7b4c
commit
5256678901
2 changed files with 43 additions and 33 deletions
|
@ -1,37 +1,10 @@
|
||||||
defmodule Pleroma.Repo.Migrations.UploadFilterExiftoolToExiftoolStripMetadata do
|
defmodule Pleroma.Repo.Migrations.UploadFilterExiftoolToExiftoolStripMetadata do
|
||||||
use Ecto.Migration
|
use Ecto.Migration
|
||||||
|
|
||||||
alias Pleroma.ConfigDB
|
# 20240425120000_upload_filter_exiftool_to_exiftool_strip_location.exs
|
||||||
|
# was originally committed with the id used in this file, but this breaks
|
||||||
def up,
|
# rollback order. Thus it was moved to 20240425120000 and this stub just prevents
|
||||||
do:
|
# errors during large-scale rollbacks for anyone who already applied the old id
|
||||||
ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Upload})
|
def up, do: :ok
|
||||||
|> update_filtername(
|
def down, do: :ok
|
||||||
Pleroma.Upload.Filter.Exiftool,
|
|
||||||
Pleroma.Upload.Filter.Exiftool.StripMetadata
|
|
||||||
)
|
|
||||||
|
|
||||||
def down,
|
|
||||||
do:
|
|
||||||
ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Upload})
|
|
||||||
|> update_filtername(
|
|
||||||
Pleroma.Upload.Filter.Exiftool.StripMetadata,
|
|
||||||
Pleroma.Upload.Filter.Exiftool
|
|
||||||
)
|
|
||||||
|
|
||||||
defp update_filtername(%{value: value}, from_filtername, to_filtername) do
|
|
||||||
new_value =
|
|
||||||
value
|
|
||||||
|> Keyword.update(:filters, [], fn filters ->
|
|
||||||
filters
|
|
||||||
|> Enum.map(fn
|
|
||||||
^from_filtername -> to_filtername
|
|
||||||
filter -> filter
|
|
||||||
end)
|
|
||||||
end)
|
|
||||||
|
|
||||||
ConfigDB.update_or_create(%{group: :pleroma, key: Pleroma.Upload, value: new_value})
|
|
||||||
end
|
|
||||||
|
|
||||||
defp update_filtername(_, _, _), do: nil
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
defmodule Pleroma.Repo.Migrations.UploadFilterExiftoolToExiftoolStripMetadataReal do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
alias Pleroma.ConfigDB
|
||||||
|
|
||||||
|
def up,
|
||||||
|
do:
|
||||||
|
ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Upload})
|
||||||
|
|> update_filtername(
|
||||||
|
Pleroma.Upload.Filter.Exiftool,
|
||||||
|
Pleroma.Upload.Filter.Exiftool.StripMetadata
|
||||||
|
)
|
||||||
|
|
||||||
|
def down,
|
||||||
|
do:
|
||||||
|
ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Upload})
|
||||||
|
|> update_filtername(
|
||||||
|
Pleroma.Upload.Filter.Exiftool.StripMetadata,
|
||||||
|
Pleroma.Upload.Filter.Exiftool
|
||||||
|
)
|
||||||
|
|
||||||
|
defp update_filtername(%{value: value}, from_filtername, to_filtername) do
|
||||||
|
new_value =
|
||||||
|
value
|
||||||
|
|> Keyword.update(:filters, [], fn filters ->
|
||||||
|
filters
|
||||||
|
|> Enum.map(fn
|
||||||
|
^from_filtername -> to_filtername
|
||||||
|
filter -> filter
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
ConfigDB.update_or_create(%{group: :pleroma, key: Pleroma.Upload, value: new_value})
|
||||||
|
end
|
||||||
|
|
||||||
|
defp update_filtername(_, _, _), do: nil
|
||||||
|
end
|
Loading…
Reference in a new issue