Creating the vote record migration

To do this, we'll need to add another table to our database. This new table will have the explicit purpose of recording votes for each poll, which right now can just be something as simple as a list of IP addresses that have voted on a particular poll. It's a pretty simple feature and design, so we'll keep the table structure equally simple. Let's first create the migration for our vote_records table, which will record the poll_id and the ip_address:

$ mix ecto.gen.migration add_vote_records_table* creating priv/repo/migrations* creating priv/repo/migrations/20171125044437_add_vote_records_table.exs

We'll give it a very simple migration since our table design is also very simple:

defmodule Vocial.Repo.Migrations.AddVoteRecordsTable ...

Get Phoenix Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.