summaryrefslogtreecommitdiff
path: root/priv/repo
diff options
context:
space:
mode:
Diffstat (limited to 'priv/repo')
-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
-rw-r--r--priv/repo/seeds.exs11
4 files changed, 58 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
diff --git a/priv/repo/seeds.exs b/priv/repo/seeds.exs
new file mode 100644
index 0000000..77639be
--- /dev/null
+++ b/priv/repo/seeds.exs
@@ -0,0 +1,11 @@
+# Script for populating the database. You can run it as:
+#
+# mix run priv/repo/seeds.exs
+#
+# Inside the script, you can read and write to any of your
+# repositories directly:
+#
+# Aggiedit.Repo.insert!(%Aggiedit.SomeSchema{})
+#
+# We recommend using the bang functions (`insert!`, `update!`
+# and so on) as they will fail if something goes wrong. \ No newline at end of file