move to 2.5.5
[anni] / priv / repo / migrations / 20210203141144_add_featured_address_to_users.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.AddFeaturedAddressToUsers do
6   use Ecto.Migration
7
8   def up do
9     alter table(:users) do
10       add(:featured_address, :string)
11     end
12
13     create(index(:users, [:featured_address]))
14
15     execute("""
16
17     update users set featured_address = concat(ap_id, '/collections/featured') where local = true and featured_address is null;
18
19     """)
20   end
21
22   def down do
23     alter table(:users) do
24       remove(:featured_address)
25     end
26   end
27 end