Add tags schema.
This commit is contained in:
parent
fa9760a94b
commit
7210b38757
17
lib/jol/blog/tags.ex
Normal file
17
lib/jol/blog/tags.ex
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
defmodule JOL.Blog.Tags do
|
||||||
|
use Ecto.Schema
|
||||||
|
import Ecto.Changeset
|
||||||
|
|
||||||
|
schema "tags" do
|
||||||
|
field :name, :string
|
||||||
|
|
||||||
|
timestamps(type: :utc_datetime)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def changeset(tags, attrs) do
|
||||||
|
tags
|
||||||
|
|> cast(attrs, [:name])
|
||||||
|
|> validate_required([:name])
|
||||||
|
end
|
||||||
|
end
|
11
priv/repo/migrations/20240924145806_create_tags.exs
Normal file
11
priv/repo/migrations/20240924145806_create_tags.exs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
defmodule JOL.Repo.Migrations.CreateTags do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
create table(:tags) do
|
||||||
|
add :name, :string
|
||||||
|
|
||||||
|
timestamps(type: :utc_datetime)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue