Migrations
As we've already seen, the purpose of our Media schema is to represent the data that we retrieve from the database in the Elixir world. Since we are using a relational database, data is persisted in database tables.
To create the tables, instead of executing a SQL script directly on the database, we will use Ecto migrations to apply every database schema change for us.
Migrations live on the priv/repo/migrations folder as Elixir scripts and their name should abide by the <timestamp>_<snake_case_name>.exs format, for example 20180112095312_create_media.exs. To execute a migration or roll back an existing one, you should use ecto.migrate or ecto.rollback, respectively.
Here's the CreateMedia migration responsible for the creation ...
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.
Read now
Unlock full access