diff options
Diffstat (limited to 'priv/repo')
| -rw-r--r-- | priv/repo/migrations/20190516112144_add_ap_id_to_lists.exs | 26 | ||||
| -rw-r--r-- | priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs | 24 | 
2 files changed, 50 insertions, 0 deletions
diff --git a/priv/repo/migrations/20190516112144_add_ap_id_to_lists.exs b/priv/repo/migrations/20190516112144_add_ap_id_to_lists.exs new file mode 100644 index 000000000..3c32bc355 --- /dev/null +++ b/priv/repo/migrations/20190516112144_add_ap_id_to_lists.exs @@ -0,0 +1,26 @@ +defmodule Pleroma.Repo.Migrations.AddApIdToLists do +  use Ecto.Migration + +  def up do +    alter table(:lists) do +      add(:ap_id, :string) +    end + +    execute(""" +    UPDATE lists +    SET ap_id = u.ap_id || '/lists/' || lists.id +    FROM users AS u +    WHERE lists.user_id = u.id +    """) + +    create(unique_index(:lists, :ap_id)) +  end + +  def down do +    drop(index(:lists, [:ap_id])) + +    alter table(:lists) do +      remove(:ap_id) +    end +  end +end diff --git a/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs b/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs new file mode 100644 index 000000000..50669902e --- /dev/null +++ b/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs @@ -0,0 +1,24 @@ +defmodule Pleroma.Repo.Migrations.CopyMutedToMutedNotifications do +  use Ecto.Migration +  alias Pleroma.User + +  def change do +    query = +      User.Query.build(%{ +        local: true, +        active: true, +        order_by: :id +      }) + +    Pleroma.Repo.stream(query) +    |> Enum.each(fn +      %{info: %{mutes: mutes} = info} = user -> +        info_cng = +          Ecto.Changeset.cast(info, %{muted_notifications: mutes}, [:muted_notifications]) + +        Ecto.Changeset.change(user) +        |> Ecto.Changeset.put_embed(:info, info_cng) +        |> Pleroma.Repo.update() +    end) +  end +end  | 
