Specify Up and Down Operations
Understand how to define separate up and down functions in Ecto migrations to manage database schema changes safely. Learn to specify rollback steps manually for migrations that alter data or structure in complex ways, ensuring reliable reversions when needed.
We'll cover the following...
We'll cover the following...
In the last section, we created a migration that altered data and structure, but we left out an important step. In its current form, this migration can’t be rolled back.
Ecto can’t reverse the removal of a column because it wouldn’t know what type it should be restored back to. We certainly can’t expect Ecto to figure out how to reverse the data transformation we did between compositions and compositions_artists. We need to ...