A free and open-source book on ZF3 for beginners


13. Database Migrations

When you are developing your website, you are constantly modifying your database schema: some tables are being added, others are being modified, unneeded tables are being deleted. Managing database schema may become a very complex task, because you need to keep it up-to-date on your development, testing and production servers. You can greatly simplify the task of managing database schema with the concept of migrations.

A migration is some kind of atomic change of state of the database schema. You can apply a migration to upgrade the schema to its newer state, or you can revert a migration to downgrade schema to its previous state. You create new migrations as you develop your website, and you can have as many migrations as you need. All migrations form a database schema change history, which is very convenient, because you know when and for what purpose you changed the schema.


Top