This commit is contained in:
Mirai Kumiko 2025-07-04 10:25:40 +02:00
parent b35e18cd20
commit 82f55f7afe
Signed by: miraikumiko
GPG key ID: 3F178B1B5E0CB278
80 changed files with 6687 additions and 5 deletions

View file

@ -0,0 +1,30 @@
defmodule Nulla.Repo.Migrations.CreateUsersAuthTables do
use Ecto.Migration
def change do
execute "CREATE EXTENSION IF NOT EXISTS citext", ""
create table(:users, primary_key: false) do
add :id, :bigint, primary_key: true
add :email, :citext, null: false
add :hashed_password, :string, null: false
add :confirmed_at, :utc_datetime
timestamps(type: :utc_datetime)
end
create unique_index(:users, [:email])
create table(:users_tokens) do
add :user_id, references(:users, on_delete: :delete_all), null: false
add :token, :binary, null: false
add :context, :string, null: false
add :sent_to, :string
timestamps(type: :utc_datetime, updated_at: false)
end
create index(:users_tokens, [:user_id])
create unique_index(:users_tokens, [:context, :token])
end
end

View file

@ -0,0 +1,41 @@
defmodule Nulla.Repo.Migrations.CreateActors do
use Ecto.Migration
def change do
create table(:actors, primary_key: false) do
add :id, :bigint, primary_key: true
add :acct, :string
add :ap_id, :string
add :type, :string
add :following, :string
add :followers, :string
add :inbox, :string
add :outbox, :string
add :featured, :string
add :featuredTags, :string
add :preferredUsername, :string
add :name, :string
add :summary, :string
add :url, :string
add :manuallyApprovesFollowers, :boolean, default: false, null: false
add :discoverable, :boolean, default: true, null: false
add :indexable, :boolean, default: true, null: false
add :published, :utc_datetime
add :memorial, :boolean, default: false, null: false
add :publicKey, :map
add :privateKeyPem, :text
add :tag, {:array, :map}, default: []
add :attachment, {:array, :map}, default: []
add :endpoints, :map
add :icon, :map
add :image, :map
add :vcard_bday, :date
add :vcard_Address, :string
timestamps(type: :utc_datetime)
end
create unique_index(:actors, [:acct])
create unique_index(:actors, [:ap_id])
end
end

View file

@ -0,0 +1,23 @@
defmodule Nulla.Repo.Migrations.CreateNotes do
use Ecto.Migration
def change do
create table(:notes, primary_key: false) do
add :id, :bigint, primary_key: true
add :inReplyTo, :string
add :published, :utc_datetime
add :url, :string
add :visibility, :string
add :to, {:array, :string}
add :cc, {:array, :string}
add :sensitive, :boolean, default: false, null: false
add :content, :string
add :language, :string
add :actor_id, references(:actors, on_delete: :delete_all)
timestamps(type: :utc_datetime)
end
create index(:notes, [:actor_id])
end
end

View file

@ -0,0 +1,18 @@
defmodule Nulla.Repo.Migrations.CreateMediaAttachments do
use Ecto.Migration
def change do
create table(:media_attachments, primary_key: false) do
add :id, :bigint, primary_key: true
add :type, :string
add :mediaType, :string
add :url, :string
add :name, :string
add :width, :integer
add :height, :integer
add :note_id, references(:notes, on_delete: :delete_all), null: false
timestamps(type: :utc_datetime)
end
end
end

View file

@ -0,0 +1,21 @@
defmodule Nulla.Repo.Migrations.CreateActivities do
use Ecto.Migration
def change do
create table(:activities, primary_key: false) do
add :id, :bigint, primary_key: true
add :ap_id, :string
add :type, :string
add :actor, :string
add :object, :string
add :to, {:array, :string}
add :cc, {:array, :string}
timestamps(type: :utc_datetime)
end
create index(:activities, [:ap_id])
create index(:activities, [:type])
create index(:activities, [:actor])
end
end

View file

@ -0,0 +1,30 @@
defmodule Nulla.Repo.Migrations.CreateRelations do
use Ecto.Migration
def change do
create table(:relations) do
add :following, :boolean, default: false, null: false
add :followed_by, :boolean, default: false, null: false
add :showing_replies, :boolean, default: false, null: false
add :showings_reblogs, :boolean, default: false, null: false
add :notifying, :boolean, default: false, null: false
add :muting, :boolean, default: false, null: false
add :muting_notifications, :boolean, default: false, null: false
add :blocking, :boolean, default: false, null: false
add :blocked_by, :boolean, default: false, null: false
add :domain_blocking, :boolean, default: false, null: false
add :requested, :boolean, default: false, null: 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(type: :utc_datetime)
end
create index(:relations, [:local_actor_id])
create index(:relations, [:remote_actor_id])
create unique_index(:relations, [:local_actor_id, :remote_actor_id])
end
end