Add models and migrations
This commit is contained in:
parent
182523d36d
commit
9e542bc790
33 changed files with 597 additions and 125 deletions
|
@ -9,6 +9,10 @@ defmodule Nulla.Repo.Migrations.CreateInstanceSettings do
|
|||
add :registration, :boolean, default: false, null: false
|
||||
add :max_characters, :integer, default: 5000, null: false
|
||||
add :max_upload_size, :integer, default: 50, null: false
|
||||
add :public_key, :string
|
||||
add :private_key, :string
|
||||
|
||||
timestamps()
|
||||
end
|
||||
end
|
||||
end
|
|
@ -7,7 +7,6 @@ defmodule Nulla.Repo.Migrations.CreateUsers do
|
|||
add :email, :string
|
||||
add :password, :string
|
||||
add :is_moderator, :boolean, default: false, null: false
|
||||
|
||||
add :realname, :string
|
||||
add :bio, :string
|
||||
add :location, :string
|
||||
|
|
18
priv/repo/migrations/20250604083506_create_notes.exs
Normal file
18
priv/repo/migrations/20250604083506_create_notes.exs
Normal file
|
@ -0,0 +1,18 @@
|
|||
defmodule Nulla.Repo.Migrations.CreateNotes do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:notes) do
|
||||
add :content, :string
|
||||
add :visibility, :string, default: "public"
|
||||
add :sensitive, :boolean, default: false
|
||||
add :language, :string
|
||||
add :in_reply_to, :string
|
||||
add :user_id, references(:users, on_delete: :delete_all)
|
||||
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
|
||||
create index(:notes, [:user_id])
|
||||
end
|
||||
end
|
14
priv/repo/migrations/20250606100445_create_bookmarks.exs
Normal file
14
priv/repo/migrations/20250606100445_create_bookmarks.exs
Normal file
|
@ -0,0 +1,14 @@
|
|||
defmodule Nulla.Repo.Migrations.CreateBookmarks do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:bookmarks) do
|
||||
add :url, :string
|
||||
add :user_id, references(:users, on_delete: :delete_all)
|
||||
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
|
||||
create index(:bookmarks, [:user_id])
|
||||
end
|
||||
end
|
18
priv/repo/migrations/20250606103230_create_notifications.exs
Normal file
18
priv/repo/migrations/20250606103230_create_notifications.exs
Normal file
|
@ -0,0 +1,18 @@
|
|||
defmodule Nulla.Repo.Migrations.CreateNotifications do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:notifications) do
|
||||
add :user_id, references(:users, on_delete: :delete_all), null: false
|
||||
add :actor_id, references(:users, on_delete: :nilify_all)
|
||||
add :type, :string, null: false
|
||||
add :data, :map
|
||||
add :read, :boolean, default: false, null: false
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create index(:notifications, [:user_id])
|
||||
create index(:notifications, [:actor_id])
|
||||
end
|
||||
end
|
|
@ -0,0 +1,19 @@
|
|||
defmodule Nulla.Repo.Migrations.CreateModerationLogs do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:moderation_logs) do
|
||||
add :moderator_id, references(:users, on_delete: :nilify_all), null: false
|
||||
add :target_type, :string, null: false
|
||||
add :target_id, :string, null: false
|
||||
add :action, :string, null: false
|
||||
add :reason, :text
|
||||
add :metadata, :map
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create index(:moderation_logs, [:moderator_id])
|
||||
create index(:moderation_logs, [:target_type, :target_id])
|
||||
end
|
||||
end
|
14
priv/repo/migrations/20250606103649_create_hashtags.exs
Normal file
14
priv/repo/migrations/20250606103649_create_hashtags.exs
Normal file
|
@ -0,0 +1,14 @@
|
|||
defmodule Nulla.Repo.Migrations.CreateHashtags do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:hashtags) do
|
||||
add :tag, :string, null: false
|
||||
add :usage_count, :integer, default: 0, null: false
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create unique_index(:hashtags, [:tag])
|
||||
end
|
||||
end
|
15
priv/repo/migrations/20250606103707_create_follows.exs
Normal file
15
priv/repo/migrations/20250606103707_create_follows.exs
Normal file
|
@ -0,0 +1,15 @@
|
|||
defmodule Nulla.Repo.Migrations.CreateFollows do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:follows) do
|
||||
add :user_id, references(:users, on_delete: :delete_all), null: false
|
||||
add :target_id, references(:users, on_delete: :delete_all), null: false
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create unique_index(:follows, [:user_id, :target_id])
|
||||
create index(:follows, [:target_id])
|
||||
end
|
||||
end
|
17
priv/repo/migrations/20250606131715_create_sessions.exs
Normal file
17
priv/repo/migrations/20250606131715_create_sessions.exs
Normal file
|
@ -0,0 +1,17 @@
|
|||
defmodule Nulla.Repo.Migrations.CreateSessions do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:sessions) do
|
||||
add :user_id, references(:users, on_delete: :delete_all), null: false
|
||||
add :token, :string, null: false
|
||||
add :user_agent, :string
|
||||
add :ip, :string
|
||||
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
|
||||
create index(:sessions, [:user_id])
|
||||
create unique_index(:sessions, [:token])
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
defmodule Nulla.Repo.Migrations.CreateMediaAttachments do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:media_attachments) do
|
||||
add :note_id, references(:notes, on_delete: :delete_all), null: false
|
||||
add :file, :string, null: false
|
||||
add :mime_type, :string
|
||||
add :description, :string
|
||||
|
||||
timestamps(type: :utc_datetime)
|
||||
end
|
||||
|
||||
create index(:media_attachments, [:note_id])
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue