From 2a4587f201b06a0a0a2dacaacd77ba3b82955902 Mon Sep 17 00:00:00 2001 From: Oneric Date: Sat, 11 Jan 2025 21:25:00 +0100 Subject: [PATCH] Fix SigningKey db schema --- ...20250112000000_signing_key_nullability.exs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 priv/repo/migrations/20250112000000_signing_key_nullability.exs diff --git a/priv/repo/migrations/20250112000000_signing_key_nullability.exs b/priv/repo/migrations/20250112000000_signing_key_nullability.exs new file mode 100644 index 000000000..02862a5c0 --- /dev/null +++ b/priv/repo/migrations/20250112000000_signing_key_nullability.exs @@ -0,0 +1,24 @@ +defmodule Pleroma.Repo.Migrations.SigningKeyNullability do + use Ecto.Migration + + import Ecto.Query + + def up() do + # Delete existing NULL entries; they are useless + Pleroma.User.SigningKey + |> where([s], is_nil(s.user_id) or is_nil(s.public_key)) + |> Pleroma.Repo.delete_all() + + alter table(:signing_keys) do + modify :user_id, :uuid, null: false + modify :public_key, :text, null: false + end + end + + def down() do + alter table(:signing_keys) do + modify :user_id, :uuid, null: true + modify :public_key, :text, null: true + end + end +end