summaryrefslogtreecommitdiff
path: root/priv/repo/migrations/20200401030751_users_add_public_key.exs
blob: 91ff371b12452d7295e0eddeaa3c0ad5b35bab54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Repo.Migrations.UsersAddPublicKey do
  use Ecto.Migration

  def up do
    alter table(:users) do
      add_if_not_exists(:public_key, :text)
    end

    execute("UPDATE users SET public_key = source_data->'publicKey'->>'publicKeyPem'")
  end

  def down do
    alter table(:users) do
      remove_if_exists(:public_key, :text)
    end
  end
end