move to 2.5.5
[anni] / priv / repo / migrations / 20200401072456_users_add_inboxes.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.UsersAddInboxes do
6   use Ecto.Migration
7
8   def up do
9     alter table(:users) do
10       add_if_not_exists(:inbox, :text)
11       add_if_not_exists(:shared_inbox, :text)
12     end
13
14     execute("UPDATE users SET inbox = source_data->>'inbox'")
15     execute("UPDATE users SET shared_inbox = source_data->'endpoints'->>'sharedInbox'")
16   end
17
18   def down do
19     alter table(:users) do
20       remove_if_exists(:inbox, :text)
21       remove_if_exists(:shared_inbox, :text)
22     end
23   end
24 end