Add relations

This commit is contained in:
Mirai Kumiko 2025-06-18 06:35:58 +02:00
parent f43b4bd038
commit 3a57d74357
Signed by: miraikumiko
GPG key ID: 3F178B1B5E0CB278
12 changed files with 81 additions and 85 deletions

View file

@ -1,16 +0,0 @@
defmodule Nulla.Repo.Migrations.CreateFollows do
use Ecto.Migration
def change do
create table(:follows, primary_key: false) do
add :id, :bigint, primary_key: true
add :follower_id, references(:actors, on_delete: :delete_all), null: false
add :following_id, references(:actors, on_delete: :delete_all), null: false
timestamps()
end
create unique_index(:follows, [:follower_id, :following_id])
create index(:follows, [:following_id])
end
end

View file

@ -4,20 +4,28 @@ defmodule Nulla.Repo.Migrations.CreateActorRelations do
def change do
create table(:relations, primary_key: false) do
add :id, :bigint, primary_key: true
add :source_id, :bigint, null: false
add :target_id, :bigint, null: false
add :type, :string, null: false
add :status, :string, null: false
add :activity_id, :bigint
add :following, :boolean, null: false, default: false
add :followed_by, :boolean, null: false, default: false
add :showing_replies, :boolean, null: false, default: true
add :showing_reblogs, :boolean, null: false, default: true
add :notifying, :boolean, null: false, default: false
add :muting, :boolean, null: false, default: false
add :muting_notifications, :boolean, null: false, default: false
add :blocking, :boolean, null: false, default: false
add :blocked_by, :boolean, null: false, default: false
add :domain_blocking, :boolean, null: false, default: false
add :requested, :boolean, null: false, default: false
add :note, :string
add :local_actor_id, references(:actors, type: :bigint), null: false
add :remote_actor_id, references(:actors, type: :bigint), null: false
timestamps()
end
create index(:relations, [:source_id])
create index(:relations, [:target_id])
create index(:relations, [:type])
create index(:relations, [:activity_id])
create index(:relations, [:local_actor_id])
create index(:relations, [:remote_actor_id])
create unique_index(:relations, [:source_id, :target_id, :type])
create unique_index(:relations, [:local_actor_id, :remote_actor_id])
end
end