summaryrefslogtreecommitdiff
path: root/priv/repo/migrations/20210203141144_add_featured_address_to_users.exs
blob: 0821662371fa51397cfe455ace973abef76ce2e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 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.AddFeaturedAddressToUsers do
  use Ecto.Migration

  def up do
    alter table(:users) do
      add(:featured_address, :string)
    end

    create(index(:users, [:featured_address]))

    execute("""

    update users set featured_address = concat(ap_id, '/collections/featured') where local = true and featured_address is null;

    """)
  end

  def down do
    alter table(:users) do
      remove(:featured_address)
    end
  end
end