From 9613fcebde2f5987f88162c248e75e08394ee1e3 Mon Sep 17 00:00:00 2001 From: supercmmetry Date: Mon, 9 Aug 2021 14:28:53 +0530 Subject: [PATCH] feat(user): add ecto migration for user Signed-off-by: supercmmetry --- lib/ketbin/api/user.ex | 3 +++ lib/ketbin/arch.ex | 18 ++++++++++++++++++ lib/ketbin/crud/user.ex | 3 +++ lib/ketbin/schema/user.ex | 17 +++++++++++++++++ .../migrations/20210809085801_create_users.exs | 12 ++++++++++++ 5 files changed, 53 insertions(+) create mode 100644 lib/ketbin/api/user.ex create mode 100644 lib/ketbin/arch.ex create mode 100644 lib/ketbin/crud/user.ex create mode 100644 lib/ketbin/schema/user.ex create mode 100644 priv/repo/migrations/20210809085801_create_users.exs diff --git a/lib/ketbin/api/user.ex b/lib/ketbin/api/user.ex new file mode 100644 index 0000000..8f4f9bc --- /dev/null +++ b/lib/ketbin/api/user.ex @@ -0,0 +1,3 @@ +defmodule Ketbin.Api.User do + +end \ No newline at end of file diff --git a/lib/ketbin/arch.ex b/lib/ketbin/arch.ex new file mode 100644 index 0000000..df38547 --- /dev/null +++ b/lib/ketbin/arch.ex @@ -0,0 +1,18 @@ +defmodule Ketbin.Schema do + @moduledoc """ + Ketbin keeps the contexts that define your schemas + """ +end + + +defmodule Ketbin.Crud do + @moduledoc """ + Ketbin keeps the contexts that define your CRUD functions + """ +end + +defmodule Ketbin.Api do + @moduledoc """ + Ketbin keeps the contexts that define your business logic. + """ +end \ No newline at end of file diff --git a/lib/ketbin/crud/user.ex b/lib/ketbin/crud/user.ex new file mode 100644 index 0000000..fc89cf4 --- /dev/null +++ b/lib/ketbin/crud/user.ex @@ -0,0 +1,3 @@ +defmodule Ketbin.Crud.User do + +end \ No newline at end of file diff --git a/lib/ketbin/schema/user.ex b/lib/ketbin/schema/user.ex new file mode 100644 index 0000000..4e0fc8e --- /dev/null +++ b/lib/ketbin/schema/user.ex @@ -0,0 +1,17 @@ +defmodule Ketbin.Schema.User do + use Ecto.Schema + import Ecto.Changeset + + schema "users" do + field :firebase_id, :string + + timestamps() + end + + @doc false + def changeset(user, attrs) do + user + |> cast(attrs, [:firebase_id]) + |> validate_required([:firebase_id]) + end +end diff --git a/priv/repo/migrations/20210809085801_create_users.exs b/priv/repo/migrations/20210809085801_create_users.exs new file mode 100644 index 0000000..b2162b8 --- /dev/null +++ b/priv/repo/migrations/20210809085801_create_users.exs @@ -0,0 +1,12 @@ +defmodule Ketbin.Repo.Migrations.CreateUsers do + use Ecto.Migration + + def change do + create table(:users) do + add :firebase_id, :string + + timestamps() + end + + end +end