Skip to content

Commit

Permalink
Creates migration and schema for comments table
Browse files Browse the repository at this point in the history
  • Loading branch information
RobStallion committed Mar 1, 2019
1 parent 4f9b4ea commit 3818a4e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions priv/repo/test_app/migrations/20190301105228_create_comments.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
defmodule Alog.Repo.Migrations.CreateComments do
use Ecto.Migration

def change do
create table(:comments, primary_key: false) do
# cid & entry_id need to be removed later as they should be handled in execute_ddl I believe
add(:cid, :string, primary_key: true)
add(:entry_id, :string)
add(:comment, :string)
add(:deleted, :boolean, default: false)
end
end
end
17 changes: 17 additions & 0 deletions test/support/comment.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
defmodule Alog.TestApp.Comment do
use Ecto.Schema
import Ecto.Changeset

# I'd imagine we'll change string as the type but
@primary_key {:cid, :string, autogenerate: false}
schema "users" do
field(:entry_id, :string)
field(:comment, :string)
field(:deleted, :boolean, default: false)
end

def changeset(comment_struct, attrs \\ %{}) do
comment_struct
|> cast(attrs, [:cid, :entry_id, :comment, :deleted])
end
end

0 comments on commit 3818a4e

Please sign in to comment.