summaryrefslogtreecommitdiff
path: root/priv/repo/migrations
diff options
context:
space:
mode:
authorLogan Hunt <loganhunt@simponic.xyz>2022-04-06 12:13:54 -0600
committerLogan Hunt <loganhunt@simponic.xyz>2022-04-06 12:13:54 -0600
commit2055742911201258e6f755b3eb4031a1b09407f1 (patch)
treea8e0471cab55329e2e00b5d3e2011d37bb67fdb6 /priv/repo/migrations
downloadaggiedit-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')
-rw-r--r--priv/repo/migrations/.formatter.exs4
-rw-r--r--priv/repo/migrations/20220405070421_create_rooms.exs13
-rw-r--r--priv/repo/migrations/20220405071636_create_users_auth_tables.exs30
3 files changed, 47 insertions, 0 deletions
diff --git a/priv/repo/migrations/.formatter.exs b/priv/repo/migrations/.formatter.exs
new file mode 100644
index 0000000..49f9151
--- /dev/null
+++ b/priv/repo/migrations/.formatter.exs
@@ -0,0 +1,4 @@
+[
+ import_deps: [:ecto_sql],
+ inputs: ["*.exs"]
+]
diff --git a/priv/repo/migrations/20220405070421_create_rooms.exs b/priv/repo/migrations/20220405070421_create_rooms.exs
new file mode 100644
index 0000000..308e3f8
--- /dev/null
+++ b/priv/repo/migrations/20220405070421_create_rooms.exs
@@ -0,0 +1,13 @@
+defmodule Aggiedit.Repo.Migrations.CreateRooms do
+ use Ecto.Migration
+
+ def change do
+ create table(:rooms) do
+ add :domain, :string, null: false
+
+ timestamps()
+ end
+
+ create unique_index(:rooms, [:domain])
+ end
+end
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