Running Migrations

Now that we’ve got our first migration written, let’s try running it and see what it does. Ecto provides a mix task to do this, so jump back out to the command line, and run mix ecto.migrate. You should see something like this:

  06:57:27.065 [info] == Running
  MusicDB.Repo.Migrations.AddCompositionsTable.change/0 forward
  06:57:27.065 [info] create table compositions
  06:57:27.069 [info] == Migrated ​in ​0.0s

This tells us that the migration was successful, and Ecto added our new table.

Let’s take a peek at our database and see what it did.

We’re going to open our database console so we can examine the tables directly. The following examples will show the steps for working with PostgreSQL—if you’re ...

Get Programming Ecto now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.