91ff371b12452d7295e0eddeaa3c0ad5b35bab54
[anni] / priv / repo / migrations / 20200401030751_users_add_public_key.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Repo.Migrations.UsersAddPublicKey do
6   use Ecto.Migration
7
8   def up do
9     alter table(:users) do
10       add_if_not_exists(:public_key, :text)
11     end
12
13     execute("UPDATE users SET public_key = source_data->'publicKey'->>'publicKeyPem'")
14   end
15
16   def down do
17     alter table(:users) do
18       remove_if_exists(:public_key, :text)
19     end
20   end
21 end