Why do we need migrations?

Why did they come up with them, if you can throw out a dump together with the source code?

I feel that the question is the stupidest ^^ do not throw slippers.

Author: moron, 2014-06-04

2 answers

Most often, migration is used to properly move the database to a new structure. In projects, it often happens that before everything went according to the same structure, and then the existing database needs to be redone, but the data can not be lost in any way. To do this, use migration.

 4
Author: Эмиль Сабитов, 2014-06-05 12:17:51

Migration, in this context, is a change in the database structure from one version to another (usually newer).

Therefore, I suggest that in cases where the context is not obvious, use a more precise term: versioned database migration.

Why is this necessary?

The database version must match the application version. They are inseparable parts of one whole. This means that when a new version of the app is delivered to production, you must also update the database version, otherwise the application will simply not be able to work correctly.

Here is a good full answer that will give food for thought:
Versioned database structure migration: basic approaches

 2
Author: Александр Наумкин, 2020-03-06 05:49:28