mirror of
https://github.com/kevin-DL/phoenix_api_template.git
synced 2026-01-17 21:14:52 +00:00
Create user
Create profile added some validation
This commit is contained in:
15
priv/repo/migrations/20230217000026_create_users.exs
Normal file
15
priv/repo/migrations/20230217000026_create_users.exs
Normal file
@@ -0,0 +1,15 @@
|
||||
defmodule PhoenixApiTemplate.Repo.Migrations.CreateUsers do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:users, primary_key: false) do
|
||||
add :id, :binary_id, primary_key: true
|
||||
add :email, :string
|
||||
add :hashed_password, :string
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create unique_index(:users, [:email])
|
||||
end
|
||||
end
|
||||
15
priv/repo/migrations/20230217000554_create_profiles.exs
Normal file
15
priv/repo/migrations/20230217000554_create_profiles.exs
Normal file
@@ -0,0 +1,15 @@
|
||||
defmodule PhoenixApiTemplate.Repo.Migrations.CreateProfiles do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:profiles, primary_key: false) do
|
||||
add(:id, :binary_id, primary_key: true)
|
||||
add(:display_name, :string)
|
||||
add(:user_id, references(:users, on_delete: :delete_all, type: :binary_id))
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create(index(:profiles, [:user_id, :display_name]))
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user