diff --git a/priv/repo/migrations/20250527054942_create_instance_settings.exs b/priv/repo/migrations/20250527054942_create_instance_settings.exs index 64c45f0..0f63ca5 100644 --- a/priv/repo/migrations/20250527054942_create_instance_settings.exs +++ b/priv/repo/migrations/20250527054942_create_instance_settings.exs @@ -22,8 +22,8 @@ defmodule Nulla.Repo.Migrations.CreateInstanceSettings do flush() execute(fn -> - {public_key, private_key} = Nulla.KeyGen.generate_keys() - now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second) + {public_key, private_key} = Nulla.KeyGen.gen() + now = DateTime.utc_now() domain = Application.get_env(:nulla, NullaWeb.Endpoint, []) diff --git a/priv/repo/migrations/20250530110822_create_users.exs b/priv/repo/migrations/20250530110822_create_users.exs deleted file mode 100644 index 2b48cfa..0000000 --- a/priv/repo/migrations/20250530110822_create_users.exs +++ /dev/null @@ -1,32 +0,0 @@ -defmodule Nulla.Repo.Migrations.CreateUsers do - use Ecto.Migration - - def change do - create table(:users, primary_key: false) do - add :id, :bigint, primary_key: true - add :username, :string, null: false, unique: true - add :domain, :string, null: false - add :email, :string - add :password, :string - add :is_moderator, :boolean, default: false, null: false - add :realname, :string - add :bio, :text - add :location, :string - add :birthday, :date - add :fields, :jsonb, default: "[]", null: false - add :tags, {:array, :string} - add :follow_approval, :boolean, default: false, null: false - add :is_bot, :boolean, default: false, null: false - add :is_discoverable, :boolean, default: true, null: false - add :is_indexable, :boolean, default: true, null: false - add :is_memorial, :boolean, default: false, null: false - add :private_key, :string, null: false - add :public_key, :string, null: false - add :avatar, :string - add :banner, :string - add :last_active_at, :utc_datetime - - timestamps(type: :utc_datetime) - end - end -end diff --git a/priv/repo/migrations/20250615130714_create_actors.exs b/priv/repo/migrations/20250615130714_create_actors.exs new file mode 100644 index 0000000..355f3e0 --- /dev/null +++ b/priv/repo/migrations/20250615130714_create_actors.exs @@ -0,0 +1,33 @@ +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 :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 + add :discoverable, :boolean, default: true + add :indexable, :boolean, default: true + add :published, :utc_datetime + add :memorial, :boolean, default: false + add :publicKey, :map + add :tag, {:array, :map} + add :attachment, {:array, :map} + add :endpoints, :map + add :icon, :map + add :image, :map + add :vcard_bday, :date + add :vcard_Address, :string + end + end +end diff --git a/priv/repo/migrations/20250615131158_create_users.exs b/priv/repo/migrations/20250615131158_create_users.exs new file mode 100644 index 0000000..e89889b --- /dev/null +++ b/priv/repo/migrations/20250615131158_create_users.exs @@ -0,0 +1,20 @@ +defmodule Nulla.Repo.Migrations.CreateUsers do + use Ecto.Migration + + def change do + create table(:users, primary_key: false) do + add :id, :bigint, primary_key: true + add :email, :string + add :password, :string + add :privateKeyPem, :string + add :last_active_at, :utc_datetime + + add :actor_id, references(:actors, column: :id, type: :bigint, on_delete: :delete_all), + null: false + + timestamps(type: :utc_datetime) + end + + create unique_index(:users, [:actor_id]) + end +end diff --git a/priv/repo/migrations/20250604083506_create_notes.exs b/priv/repo/migrations/20250615131431_create_notes.exs similarity index 100% rename from priv/repo/migrations/20250604083506_create_notes.exs rename to priv/repo/migrations/20250615131431_create_notes.exs diff --git a/priv/repo/migrations/20250606103527_create_moderations_logs.exs b/priv/repo/migrations/20250615131534_create_moderations_logs.exs similarity index 100% rename from priv/repo/migrations/20250606103527_create_moderations_logs.exs rename to priv/repo/migrations/20250615131534_create_moderations_logs.exs diff --git a/priv/repo/migrations/20250606131715_create_sessions.exs b/priv/repo/migrations/20250615131610_create_sessions.exs similarity index 100% rename from priv/repo/migrations/20250606131715_create_sessions.exs rename to priv/repo/migrations/20250615131610_create_sessions.exs diff --git a/priv/repo/migrations/20250606132108_create_media_attachments.exs b/priv/repo/migrations/20250615131644_create_media_attachments.exs similarity index 100% rename from priv/repo/migrations/20250606132108_create_media_attachments.exs rename to priv/repo/migrations/20250615131644_create_media_attachments.exs diff --git a/priv/repo/migrations/20250606100445_create_bookmarks.exs b/priv/repo/migrations/20250615131800_create_bookmarks.exs similarity index 100% rename from priv/repo/migrations/20250606100445_create_bookmarks.exs rename to priv/repo/migrations/20250615131800_create_bookmarks.exs diff --git a/priv/repo/migrations/20250606103707_create_follows.exs b/priv/repo/migrations/20250615131836_create_follows.exs similarity index 100% rename from priv/repo/migrations/20250606103707_create_follows.exs rename to priv/repo/migrations/20250615131836_create_follows.exs diff --git a/priv/repo/migrations/20250607124601_create_activities.exs b/priv/repo/migrations/20250615131856_create_activities.exs similarity index 100% rename from priv/repo/migrations/20250607124601_create_activities.exs rename to priv/repo/migrations/20250615131856_create_activities.exs diff --git a/priv/repo/migrations/20250606103230_create_notifications.exs b/priv/repo/migrations/20250615132202_create_notifications.exs similarity index 88% rename from priv/repo/migrations/20250606103230_create_notifications.exs rename to priv/repo/migrations/20250615132202_create_notifications.exs index ec8cbc0..34e3204 100644 --- a/priv/repo/migrations/20250606103230_create_notifications.exs +++ b/priv/repo/migrations/20250615132202_create_notifications.exs @@ -5,7 +5,7 @@ defmodule Nulla.Repo.Migrations.CreateNotifications do create table(:notifications, primary_key: false) do add :id, :bigint, primary_key: true add :user_id, references(:users, on_delete: :delete_all), null: false - add :actor_id, references(:users, on_delete: :nilify_all) + add :actor_id, references(:actors, on_delete: :nilify_all) add :type, :string, null: false add :data, :map add :read, :boolean, default: false, null: false