Skip to Content
Phoenix Web Development
book

Phoenix Web Development

by Brandon Richey
April 2018
Beginner to intermediate content levelBeginner to intermediate
406 pages
9h 33m
English
Packt Publishing
Content preview from Phoenix Web Development

Building the chat schema

Let's get to writing some code to put this all together! We'll start off by building our add_messages_table migration:

$ mix ecto.gen.migration add_messages_table* creating priv/repo/migrations* creating priv/repo/migrations/20171206203035_add_messages_table.exs

We'll want to explicitly have it create the standard Ecto timestamps, as well as our message, author, and poll_id columns. id will be created by default every time, so there's not much we need to do there. Also, since we're relying on a foreign key that will likely be used pretty frequently in our queries, we want to make sure that we're creating an index for that particular column in reference to the correct table. In the priv/repo/migrations/*_add_messages_table.exs ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Phoenix in Action

Phoenix in Action

Geoffrey Lessel
Real-Time Phoenix

Real-Time Phoenix

Stephen Bussey

Publisher Resources

ISBN: 9781787284197Supplemental Content