diff options
author | Tusooa Zhu <tusooa@kazv.moe> | 2022-07-11 15:49:58 -0400 |
---|---|---|
committer | Tusooa Zhu <tusooa@kazv.moe> | 2022-08-20 20:43:46 -0400 |
commit | 3885ee182a572a10b326ae553703ee0d38f3b66d (patch) | |
tree | e456867f8185b099ec8b83519df1c64d81c508a2 /priv/repo | |
parent | 06678fb4ad42fcaecb99eccc2237c3b863a2b9a5 (diff) | |
download | pleroma-3885ee182a572a10b326ae553703ee0d38f3b66d.tar.gz |
Switch to associated_object_id index
Diffstat (limited to 'priv/repo')
-rw-r--r-- | priv/repo/migrations/20220711192750_switch_to_associated_object_id_index.exs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/priv/repo/migrations/20220711192750_switch_to_associated_object_id_index.exs b/priv/repo/migrations/20220711192750_switch_to_associated_object_id_index.exs new file mode 100644 index 000000000..c0b89731b --- /dev/null +++ b/priv/repo/migrations/20220711192750_switch_to_associated_object_id_index.exs @@ -0,0 +1,39 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Repo.Migrations.SwitchToAssociatedObjectIdIndex do + use Ecto.Migration + @disable_ddl_transaction true + @disable_migration_lock true + + def up do + drop_if_exists( + index(:activities, ["(coalesce(data->'object'->>'id', data->>'object'))"], + name: :activities_create_objects_index + ) + ) + + create( + index(:activities, ["associated_object_id(data)"], + name: :activities_create_objects_index, + concurrently: true + ) + ) + end + + def down do + drop_if_exists( + index(:activities, ["associated_object_id(data)"], + name: :activities_create_objects_index + ) + ) + + create( + index(:activities, ["(coalesce(data->'object'->>'id', data->>'object'))"], + name: :activities_create_objects_index, + concurrently: true + ) + ) + end +end |