Run Migrations
Explore how to apply and reverse database schema changes using Ecto migrations. Understand how to run migrations, inspect database tables, manage primary and foreign keys, and roll back changes to maintain a stable development process.
Add compositions table
Now that we’ve got our first migration written, let’s try to run it and see what it does. Ecto provides a mix task to do this, so let’s jump down to the command line and run mix ecto.migrate.
You should see something like this:
This tells us that the migration was successful and Ecto added our new table.
Take a peek at the database to see the changes
Let’s take a look at our database and see what it did.
We’re going to open our database console to examine the tables directly. The following examples will show the steps for working with PostgreSQL.
We can open up a PostgreSQL console with the following command:
music_db=#
From here, we can use the \dt ...