feat: notes schema
This commit is contained in:
parent
fc799a5c0e
commit
a38d13a16a
2 changed files with 30 additions and 0 deletions
18
lib/comfycamp/note.ex
Normal file
18
lib/comfycamp/note.ex
Normal 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
|
12
priv/repo/migrations/20240725083222_create_notes.exs
Normal file
12
priv/repo/migrations/20240725083222_create_notes.exs
Normal 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
|
Loading…
Reference in a new issue