diff options
author | Logan Hunt <loganhunt@simponic.xyz> | 2022-04-06 12:13:54 -0600 |
---|---|---|
committer | Logan Hunt <loganhunt@simponic.xyz> | 2022-04-06 12:13:54 -0600 |
commit | 2055742911201258e6f755b3eb4031a1b09407f1 (patch) | |
tree | a8e0471cab55329e2e00b5d3e2011d37bb67fdb6 /priv/repo/migrations/20220405071636_create_users_auth_tables.exs | |
download | aggiedit-2055742911201258e6f755b3eb4031a1b09407f1.tar.gz aggiedit-2055742911201258e6f755b3eb4031a1b09407f1.zip |
Initial commit; generate auth code with phx.gen.auth; added room model and association; generate room model on domain of user emails; allow users to change their email
Diffstat (limited to 'priv/repo/migrations/20220405071636_create_users_auth_tables.exs')
-rw-r--r-- | priv/repo/migrations/20220405071636_create_users_auth_tables.exs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/priv/repo/migrations/20220405071636_create_users_auth_tables.exs b/priv/repo/migrations/20220405071636_create_users_auth_tables.exs new file mode 100644 index 0000000..06bde64 --- /dev/null +++ b/priv/repo/migrations/20220405071636_create_users_auth_tables.exs @@ -0,0 +1,30 @@ +defmodule Aggiedit.Repo.Migrations.CreateUsersAuthTables 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 :hashed_password, :string, null: false + add :confirmed_at, :naive_datetime + add :role, :string + add :room_id, references(:rooms, on_delete: :delete_all) + timestamps() + end + + create unique_index(:users, [:email]) + + create table(:users_tokens) do + add :user_id, references(:users, on_delete: :delete_all), null: false + add :token, :binary, null: false + add :context, :string, null: false + add :sent_to, :string + timestamps(updated_at: false) + end + + create index(:users_tokens, [:user_id]) + create unique_index(:users_tokens, [:context, :token]) + end +end
\ No newline at end of file |