diff options
Diffstat (limited to 'priv')
4 files changed, 28 insertions, 4 deletions
| diff --git a/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs b/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs index ce4590954..c547d2642 100644 --- a/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs +++ b/priv/repo/migrations/20190414125034_migrate_old_bookmarks.exs @@ -8,10 +8,10 @@ defmodule Pleroma.Repo.Migrations.MigrateOldBookmarks do    def up do      query = -      from(u in User, +      from(u in "users",          where: u.local == true, -        where: fragment("array_length(bookmarks, 1)") > 0, -        select: %{id: u.id, bookmarks: fragment("bookmarks")} +        where: fragment("array_length(?, 1)", u.bookmarks) > 0, +        select: %{id: u.id, bookmarks: u.bookmarks}        )      Repo.stream(query) diff --git a/priv/repo/migrations/20190711042020_fix_and_secure_user_info_field.exs b/priv/repo/migrations/20190711042020_fix_and_secure_user_info_field.exs new file mode 100644 index 000000000..9602a8c41 --- /dev/null +++ b/priv/repo/migrations/20190711042020_fix_and_secure_user_info_field.exs @@ -0,0 +1,17 @@ +defmodule Pleroma.Repo.Migrations.FixAndSecureUserInfoField do +  use Ecto.Migration + +  def up do +    execute("UPDATE users SET info = '{}'::jsonb WHERE info IS NULL") + +    execute("ALTER TABLE users +    ALTER COLUMN info SET NOT NULL +    ") +  end + +  def down do +    execute("ALTER TABLE users +    ALTER COLUMN info DROP NOT NULL +    ") +  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 index a3c5b52de..c0d6b3a87 100644 --- a/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs +++ b/priv/repo/migrations/20190711042024_copy_muted_to_muted_notifications.exs @@ -3,6 +3,6 @@ defmodule Pleroma.Repo.Migrations.CopyMutedToMutedNotifications do    alias Pleroma.User    def change do -  execute("update users set info = safe_jsonb_set(info, '{muted_notifications}', info->'mutes', true) where local = true") +  execute("update users set info = safe_jsonb_set(info, '{muted_notifications}', info->'mutes', true) where local = true and info->'mutes' is not null")    end  end diff --git a/priv/repo/migrations/20191104143558_fix_null_muted_notification_fields.exs b/priv/repo/migrations/20191104143558_fix_null_muted_notification_fields.exs new file mode 100644 index 000000000..e17e75983 --- /dev/null +++ b/priv/repo/migrations/20191104143558_fix_null_muted_notification_fields.exs @@ -0,0 +1,7 @@ +defmodule Pleroma.Repo.Migrations.FixNullMutedNotificationFields do +  use Ecto.Migration + +  def change do +    execute("update users set info = safe_jsonb_set(info, '{muted_notifications}', '[]'::jsonb, true) where local = true and info->'muted_notifications' = 'null'::jsonb") +  end +end | 
