Update migrations
This commit is contained in:
parent
50abfe4748
commit
57efda7638
12 changed files with 56 additions and 35 deletions
|
@ -22,8 +22,8 @@ defmodule Nulla.Repo.Migrations.CreateInstanceSettings do
|
||||||
flush()
|
flush()
|
||||||
|
|
||||||
execute(fn ->
|
execute(fn ->
|
||||||
{public_key, private_key} = Nulla.KeyGen.generate_keys()
|
{public_key, private_key} = Nulla.KeyGen.gen()
|
||||||
now = NaiveDateTime.utc_now() |> NaiveDateTime.truncate(:second)
|
now = DateTime.utc_now()
|
||||||
|
|
||||||
domain =
|
domain =
|
||||||
Application.get_env(:nulla, NullaWeb.Endpoint, [])
|
Application.get_env(:nulla, NullaWeb.Endpoint, [])
|
||||||
|
|
|
@ -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
|
|
33
priv/repo/migrations/20250615130714_create_actors.exs
Normal file
33
priv/repo/migrations/20250615130714_create_actors.exs
Normal file
|
@ -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
|
20
priv/repo/migrations/20250615131158_create_users.exs
Normal file
20
priv/repo/migrations/20250615131158_create_users.exs
Normal file
|
@ -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
|
|
@ -5,7 +5,7 @@ defmodule Nulla.Repo.Migrations.CreateNotifications do
|
||||||
create table(:notifications, primary_key: false) do
|
create table(:notifications, primary_key: false) do
|
||||||
add :id, :bigint, primary_key: true
|
add :id, :bigint, primary_key: true
|
||||||
add :user_id, references(:users, on_delete: :delete_all), null: false
|
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 :type, :string, null: false
|
||||||
add :data, :map
|
add :data, :map
|
||||||
add :read, :boolean, default: false, null: false
|
add :read, :boolean, default: false, null: false
|
Loading…
Add table
Add a link
Reference in a new issue