With our database structure ready to go, we can create our schema file to accompany it! Create lib/vocial/votes/vote_record.ex and we'll start it off the same way we start off most of our new schemas: with macros, imports, and aliases first!
defmodule Vocial.Votes.VoteRecord do use Ecto.Schema import Ecto.Changeset alias Vocial.Votes.VoteRecord alias Vocial.Votes.Poll # ...end
The next step in building out our schema is always specifying that the schema will house our data and the shape of that schema, so we'll implement that next:
schema "vote_records" do field :ip_address, :string belongs_to :poll, Poll timestamps()end
Finally, we'll need to implement the changeset/2 function. This follows the same template ...