Merge remote-tracking branch 'origin/develop' into apps-api-endpoint

This commit is contained in:
Alex Gleason 2021-12-27 18:01:25 -06:00
commit f5c3d45120
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
3865 changed files with 4840 additions and 12084 deletions

View file

@ -14,9 +14,7 @@ defmodule Pleroma.Repo.Migrations.FillRecipientsInActivities do
max = min + 10_000
execute("""
update activities set recipients = array(select jsonb_array_elements_text(data->'to')) where id > #{
min
} and id <= #{max};
update activities set recipients = array(select jsonb_array_elements_text(data->'to')) where id > #{min} and id <= #{max};
""")
|> IO.inspect()
end)

View file

@ -28,9 +28,7 @@ defmodule Pleroma.Repo.Migrations.InsertSkeletonsForDeletedUsers do
{:ok, %{rows: ap_ids}} =
Ecto.Adapters.SQL.query(
Repo,
"select distinct unnest(nonexistent_locals.recipients) from activities, lateral (select array_agg(recipient) as recipients from unnest(activities.recipients) as recipient where recipient similar to '#{
instance_uri
}/users/[A-Za-z0-9]*' and not(recipient in (select ap_id from users))) nonexistent_locals;",
"select distinct unnest(nonexistent_locals.recipients) from activities, lateral (select array_agg(recipient) as recipients from unnest(activities.recipients) as recipient where recipient similar to '#{instance_uri}/users/[A-Za-z0-9]*' and not(recipient in (select ap_id from users))) nonexistent_locals;",
[],
timeout: :infinity
)

View file

@ -0,0 +1,9 @@
defmodule Pleroma.Repo.Migrations.RemoveMastofeSettingsFromUsers do
use Ecto.Migration
def change do
alter table(:users) do
remove_if_exists(:mastofe_settings, :map)
end
end
end

View file

@ -0,0 +1,15 @@
defmodule Pleroma.Repo.Migrations.CreateUserNotes do
use Ecto.Migration
def change do
create_if_not_exists table(:user_notes) do
add(:source_id, references(:users, type: :uuid, on_delete: :delete_all))
add(:target_id, references(:users, type: :uuid, on_delete: :delete_all))
add(:comment, :string)
timestamps()
end
create_if_not_exists(unique_index(:user_notes, [:source_id, :target_id]))
end
end

View file

@ -0,0 +1,11 @@
defmodule Pleroma.Repo.Migrations.ForcePinnedObjectsToExist do
use Ecto.Migration
def change do
execute("UPDATE users SET pinned_objects = '{}' WHERE pinned_objects IS NULL")
alter table("users") do
modify(:pinned_objects, :map, null: false, default: %{})
end
end
end

View file

@ -0,0 +1,11 @@
defmodule Pleroma.Repo.Migrations.AddSuggestions do
use Ecto.Migration
def change do
alter table(:users) do
add(:is_suggested, :boolean, default: false, null: false)
end
create_if_not_exists(index(:users, [:is_suggested]))
end
end

View file

@ -0,0 +1,11 @@
defmodule Pleroma.Repo.Migrations.AddLastStatusAtToUsers do
use Ecto.Migration
def change do
alter table(:users) do
add(:last_status_at, :naive_datetime)
end
create_if_not_exists(index(:users, [:last_status_at]))
end
end

View file

@ -0,0 +1,7 @@
defmodule Pleroma.Repo.Migrations.AddIsDiscoverableIndexToUsers do
use Ecto.Migration
def change do
create(index(:users, [:is_discoverable]))
end
end