Skip to content

Commit

Permalink
#1 mix phx.gen.schema Comment
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonic committed Oct 4, 2023
1 parent aabaf02 commit 82accb7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# `tidy`<sup>1</sup>

✨ a mini app anyone can use to organize their real-world life 🎉
✨ a mini app _anyone_ can use to **organize** their **_real-world_ life** 🪄

![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/dwyl/tidy/ci.yml?label=build&style=flat-square&branch=main)
[![codecov.io](https://img.shields.io/codecov/c/github/dwyl/tidy/main.svg?style=flat-square)](https://codecov.io/github/dwyl/tidy?branch=main)
Expand Down
19 changes: 19 additions & 0 deletions lib/tidy/comment.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
defmodule Tidy.Comment do
use Ecto.Schema
import Ecto.Changeset

schema "comments" do
field :text, :binary
field :obj_id, :integer
field :person_id, :integer

timestamps()
end

@doc false
def changeset(comment, attrs) do
comment
|> cast(attrs, [:obj_id, :person_id, :text])
|> validate_required([:obj_id, :person_id, :text])
end
end
13 changes: 13 additions & 0 deletions priv/repo/migrations/20231004142856_create_comments.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
defmodule Tidy.Repo.Migrations.CreateComments do
use Ecto.Migration

def change do
create table(:comments) do
add :obj_id, :integer
add :person_id, :integer
add :text, :binary

timestamps()
end
end
end

0 comments on commit 82accb7

Please sign in to comment.