This commit is contained in:
Mirai Kumiko 2025-06-17 12:06:36 +02:00
parent 58049c93d4
commit 894866ca03
Signed by: miraikumiko
GPG key ID: 3F178B1B5E0CB278
22 changed files with 344 additions and 213 deletions

View file

@ -4,14 +4,16 @@ defmodule Nulla.Repo.Migrations.CreateActors do
def change do
create table(:actors, primary_key: false) do
add :id, :bigint, primary_key: true
add :type, :string
add :following, :string
add :followers, :string
add :inbox, :string
add :outbox, :string
add :domain, :string
add :ap_id, :string, null: false
add :type, :string, null: false
add :following, :string, null: false
add :followers, :string, null: false
add :inbox, :string, null: false
add :outbox, :string, null: false
add :featured, :string
add :featuredTags, :string
add :preferredUsername, :string
add :preferredUsername, :string, null: false
add :name, :string
add :summary, :string
add :url, :string

View file

@ -9,11 +9,11 @@ defmodule Nulla.Repo.Migrations.CreateNotes do
add :sensitive, :boolean, default: false
add :language, :string
add :in_reply_to, :string
add :user_id, references(:users, on_delete: :delete_all)
add :actor_id, references(:actors, on_delete: :delete_all)
timestamps(type: :utc_datetime)
end
create index(:notes, [:user_id])
create index(:notes, [:actor_id])
end
end

View file

@ -4,13 +4,13 @@ defmodule Nulla.Repo.Migrations.CreateFollows do
def change do
create table(:follows, primary_key: false) do
add :id, :bigint, primary_key: true
add :user_id, references(:users, on_delete: :delete_all), null: false
add :target_id, references(:users, on_delete: :delete_all), null: false
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, [:user_id, :target_id])
create index(:follows, [:target_id])
create unique_index(:follows, [:follower_id, :following_id])
create index(:follows, [:following_id])
end
end

View file

@ -4,15 +4,16 @@ defmodule Nulla.Repo.Migrations.CreateActivities do
def change do
create table(:activities, primary_key: false) do
add :id, :bigint, primary_key: true
add :ap_id, :string, null: false
add :type, :string, null: false
add :actor, :string, null: false
add :actor_id, references(:actors, type: :bigint, on_delete: :nothing), null: false
add :object, :map, null: false
add :to, {:array, :string}, default: []
timestamps()
end
create index(:activities, [:actor])
create index(:activities, [:type])
create index(:activities, [:actor_id])
end
end

View file

@ -0,0 +1,23 @@
defmodule Nulla.Repo.Migrations.CreateActorRelations do
use Ecto.Migration
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
timestamps()
end
create index(:relations, [:source_id])
create index(:relations, [:target_id])
create index(:relations, [:type])
create index(:relations, [:activity_id])
create unique_index(:relations, [:source_id, :target_id, :type])
end
end