Changing Default Behaviors

Ecto’s migrations follow a number of conventions that have proven to work well over time. In most cases, it’s easiest to follow those conventions. They usually require less code and they can reduce ramp-up time for new developers joining the project—it’s always helpful if a new project looks a lot like your last one. But sometimes Ecto’s conventions won’t fit your project, and you need to structure things differently. Fortunately, Ecto offers a number of escape hatches that allow you to craft your migrations as needed. In this section, we’ll look at a number of different ways you can customize migration behavior.

Setting Primary and Foreign Key Names

Earlier in this chapter, we saw how Ecto automatically creates a ...

Get Programming Ecto 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.