mirror of
https://github.com/fly-apps/live_beats.git
synced 2024-11-15 20:51:03 +00:00
36 lines
1 KiB
Elixir
36 lines
1 KiB
Elixir
defmodule LiveBeats.Repo.Migrations.CreateUserAuth do
|
|
use Ecto.Migration
|
|
|
|
def change do
|
|
execute "CREATE EXTENSION IF NOT EXISTS citext", ""
|
|
|
|
create table(:users) do
|
|
add :email, :citext, null: false
|
|
add :username, :string, null: false
|
|
add :name, :string
|
|
add :role, :string, null: false
|
|
add :confirmed_at, :naive_datetime
|
|
|
|
timestamps()
|
|
end
|
|
|
|
create unique_index(:users, [:email])
|
|
create unique_index(:users, [:username])
|
|
|
|
create table(:identities) do
|
|
add :user_id, references(:users, on_delete: :delete_all), null: false
|
|
add :provider, :string, null: false
|
|
add :provider_token, :string, null: false
|
|
add :provider_login, :string, null: false
|
|
add :provider_email, :string, null: false
|
|
add :provider_id, :string, null: false
|
|
add :provider_meta, :map, default: "{}", null: false
|
|
|
|
timestamps()
|
|
end
|
|
|
|
create index(:identities, [:user_id])
|
|
create index(:identities, [:provider])
|
|
create unique_index(:identities, [:user_id, :provider])
|
|
end
|
|
end
|