diff --git a/lib/comfycamp/note.ex b/lib/comfycamp/note.ex new file mode 100644 index 0000000..3042fcb --- /dev/null +++ b/lib/comfycamp/note.ex @@ -0,0 +1,18 @@ +defmodule Comfycamp.Note do + use Ecto.Schema + import Ecto.Changeset + + schema "notes" do + field :title, :string + field :markdown, :string + + timestamps(type: :utc_datetime) + end + + @doc false + def changeset(note, attrs) do + note + |> cast(attrs, [:title, :markdown]) + |> validate_required([:title, :markdown]) + end +end diff --git a/priv/repo/migrations/20240725083222_create_notes.exs b/priv/repo/migrations/20240725083222_create_notes.exs new file mode 100644 index 0000000..9409a99 --- /dev/null +++ b/priv/repo/migrations/20240725083222_create_notes.exs @@ -0,0 +1,12 @@ +defmodule Comfycamp.Repo.Migrations.CreateNotes do + use Ecto.Migration + + def change do + create table(:notes) do + add :title, :string + add :markdown, :string + + timestamps(type: :utc_datetime) + end + end +end