diff options
author | Alex Gleason <alex@alexgleason.me> | 2021-12-30 20:19:35 -0600 |
---|---|---|
committer | Alex Gleason <alex@alexgleason.me> | 2021-12-30 20:19:35 -0600 |
commit | 668bd5da0a77f9c4974ee9775ca91f2ab59a41b0 (patch) | |
tree | 440ad674f05cfbd78fcf508da35722d58ba34d3b | |
parent | 15e6b4089959238eb497137c4eb18f0fc0983082 (diff) | |
download | pleroma-668bd5da0a77f9c4974ee9775ca91f2ab59a41b0.tar.gz |
CombineActivitiesAndObjects: add defaults, and missing indexes
-rw-r--r-- | priv/repo/migrations/20211218181647_combine_activities_and_objects.exs | 12 | ||||
-rw-r--r-- | priv/repo/migrations/20211231013155_add_object_concurrent_indexes.exs | 14 |
2 files changed, 22 insertions, 4 deletions
diff --git a/priv/repo/migrations/20211218181647_combine_activities_and_objects.exs b/priv/repo/migrations/20211218181647_combine_activities_and_objects.exs index 153ac9718..749704cf1 100644 --- a/priv/repo/migrations/20211218181647_combine_activities_and_objects.exs +++ b/priv/repo/migrations/20211218181647_combine_activities_and_objects.exs @@ -7,9 +7,9 @@ defmodule Pleroma.Repo.Migrations.CombineActivitiesAndObjects do def up do # Add missing fields to objects table alter table(:objects) do - add(:local, :boolean) + add(:local, :boolean, null: false, default: true) add(:actor, :string) - add(:recipients, {:array, :string}) + add(:recipients, {:array, :string}, default: [])) end # Add missing indexes to objects @@ -18,11 +18,15 @@ defmodule Pleroma.Repo.Migrations.CombineActivitiesAndObjects do create_if_not_exists(index(:objects, [:recipients], using: :gin)) create_if_not_exists( - index(:objects, ["(data->'to')"], name: :activities_to_index, using: :gin) + index(:objects, ["(data->'to')"], name: :objects_to_index, using: :gin) ) create_if_not_exists( - index(:objects, ["(data->'cc')"], name: :activities_cc_index, using: :gin) + index(:objects, ["(data->'cc')"], name: :objects_cc_index, using: :gin) + ) + + create_if_not_exists( + index(:objects, ["(data->>'actor')", "inserted_at desc"], name: :objects_actor_index) ) # Some obscure Fediverse backends (WordPress, Juick) send a Create and a Note diff --git a/priv/repo/migrations/20211231013155_add_object_concurrent_indexes.exs b/priv/repo/migrations/20211231013155_add_object_concurrent_indexes.exs new file mode 100644 index 000000000..370d86733 --- /dev/null +++ b/priv/repo/migrations/20211231013155_add_object_concurrent_indexes.exs @@ -0,0 +1,14 @@ +defmodule Pleroma.Repo.Migrations.AddObjectConcurrentIndexes do + use Ecto.Migration + @disable_ddl_transaction true + + def change do + create( + index(:objects, ["activity_visibility(actor, recipients, data)", "id DESC NULLS LAST"], + name: :objects_visibility_index, + concurrently: true, + where: "data->>'type' = 'Create'" + ) + ) + end +end |