1 defmodule Pleroma.Repo.Migrations.CreateFollowingRelationships do
4 # had to disable these to be able to restore `following` index concurrently
5 # https://hexdocs.pm/ecto_sql/Ecto.Migration.html#index/3-adding-dropping-indexes-concurrently
8 create_if_not_exists table(:following_relationships) do
9 add(:follower_id, references(:users, type: :uuid, on_delete: :delete_all), null: false)
10 add(:following_id, references(:users, type: :uuid, on_delete: :delete_all), null: false)
11 add(:state, :string, null: false)
16 create_if_not_exists(index(:following_relationships, :follower_id))
17 create_if_not_exists(unique_index(:following_relationships, [:follower_id, :following_id]))