feat: notes schema

This commit is contained in:
Ivan R. 2024-07-27 23:22:09 +05:00
parent fc799a5c0e
commit a38d13a16a
Signed by: lumin
GPG key ID: E0937DC7CD6D3817
2 changed files with 30 additions and 0 deletions

18
lib/comfycamp/note.ex Normal file
View file

@ -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

View file

@ -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