Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
This commit is contained in:
commit
8c2c325598
71 changed files with 1352 additions and 558 deletions
|
|
@ -0,0 +1,9 @@
|
|||
defmodule Pleroma.Repo.Migrations.AddTrustedToApps do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table(:apps) do
|
||||
add(:trusted, :boolean, default: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
17
priv/repo/migrations/20200401030751_users_add_public_key.exs
Normal file
17
priv/repo/migrations/20200401030751_users_add_public_key.exs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
defmodule Pleroma.Repo.Migrations.UsersAddPublicKey do
|
||||
use Ecto.Migration
|
||||
|
||||
def up do
|
||||
alter table(:users) do
|
||||
add_if_not_exists(:public_key, :text)
|
||||
end
|
||||
|
||||
execute("UPDATE users SET public_key = source_data->'publicKey'->>'publicKeyPem'")
|
||||
end
|
||||
|
||||
def down do
|
||||
alter table(:users) do
|
||||
remove_if_exists(:public_key, :text)
|
||||
end
|
||||
end
|
||||
end
|
||||
20
priv/repo/migrations/20200401072456_users_add_inboxes.exs
Normal file
20
priv/repo/migrations/20200401072456_users_add_inboxes.exs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
defmodule Pleroma.Repo.Migrations.UsersAddInboxes do
|
||||
use Ecto.Migration
|
||||
|
||||
def up do
|
||||
alter table(:users) do
|
||||
add_if_not_exists(:inbox, :text)
|
||||
add_if_not_exists(:shared_inbox, :text)
|
||||
end
|
||||
|
||||
execute("UPDATE users SET inbox = source_data->>'inbox'")
|
||||
execute("UPDATE users SET shared_inbox = source_data->'endpoints'->>'sharedInbox'")
|
||||
end
|
||||
|
||||
def down do
|
||||
alter table(:users) do
|
||||
remove_if_exists(:inbox, :text)
|
||||
remove_if_exists(:shared_inbox, :text)
|
||||
end
|
||||
end
|
||||
end
|
||||
35
priv/repo/migrations/20200406100225_users_add_emoji.exs
Normal file
35
priv/repo/migrations/20200406100225_users_add_emoji.exs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
defmodule Pleroma.Repo.Migrations.UsersPopulateEmoji do
|
||||
use Ecto.Migration
|
||||
|
||||
import Ecto.Query
|
||||
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Repo
|
||||
|
||||
def up do
|
||||
execute("ALTER TABLE users ALTER COLUMN emoji SET DEFAULT '{}'::jsonb")
|
||||
execute("UPDATE users SET emoji = DEFAULT WHERE emoji = '[]'::jsonb")
|
||||
|
||||
from(u in User)
|
||||
|> select([u], struct(u, [:id, :ap_id, :source_data]))
|
||||
|> Repo.stream()
|
||||
|> Enum.each(fn user ->
|
||||
emoji =
|
||||
user.source_data
|
||||
|> Map.get("tag", [])
|
||||
|> Enum.filter(fn data -> data["type"] == "Emoji" and data["icon"] end)
|
||||
|> Enum.reduce(%{}, fn %{"icon" => %{"url" => url}, "name" => name}, acc ->
|
||||
Map.put(acc, String.trim(name, ":"), url)
|
||||
end)
|
||||
|
||||
user
|
||||
|> Ecto.Changeset.cast(%{emoji: emoji}, [:emoji])
|
||||
|> Repo.update()
|
||||
end)
|
||||
end
|
||||
|
||||
def down do
|
||||
execute("ALTER TABLE users ALTER COLUMN emoji SET DEFAULT '[]'::jsonb")
|
||||
execute("UPDATE users SET emoji = DEFAULT WHERE emoji = '{}'::jsonb")
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
defmodule Pleroma.Repo.Migrations.UsersRemoveSourceData do
|
||||
use Ecto.Migration
|
||||
|
||||
def up do
|
||||
alter table(:users) do
|
||||
remove_if_exists(:source_data, :map)
|
||||
end
|
||||
end
|
||||
|
||||
def down do
|
||||
alter table(:users) do
|
||||
add_if_not_exists(:source_data, :map, default: %{})
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue