summaryrefslogtreecommitdiff
path: root/priv/repo/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'priv/repo/migrations')
-rw-r--r--priv/repo/migrations/20221219082326_create_player.exs15
-rw-r--r--priv/repo/migrations/20221219215005_add_keys.exs14
2 files changed, 29 insertions, 0 deletions
diff --git a/priv/repo/migrations/20221219082326_create_player.exs b/priv/repo/migrations/20221219082326_create_player.exs
new file mode 100644
index 0000000..b99bb5e
--- /dev/null
+++ b/priv/repo/migrations/20221219082326_create_player.exs
@@ -0,0 +1,15 @@
+defmodule Chessh.Repo.Migrations.CreatePlayer do
+ use Ecto.Migration
+
+ def change do
+ execute "CREATE EXTENSION IF NOT EXISTS citext", ""
+
+ create table(:players) do
+ add :username, :citext, null: false
+ add :hashed_password, :string, null: false
+ timestamps()
+ end
+
+ create unique_index(:players, [:username])
+ end
+end
diff --git a/priv/repo/migrations/20221219215005_add_keys.exs b/priv/repo/migrations/20221219215005_add_keys.exs
new file mode 100644
index 0000000..15163dc
--- /dev/null
+++ b/priv/repo/migrations/20221219215005_add_keys.exs
@@ -0,0 +1,14 @@
+defmodule Chessh.Repo.Migrations.AddKeys do
+ use Ecto.Migration
+
+ def change do
+ create table(:keys) do
+ add :key, :string, null: false
+ add :name, :string, null: false
+
+ add :player_id, references(:players)
+
+ timestamps()
+ end
+ end
+end