Answer the question
In order to leave comments, you need to log in
What is the purpose of database migrations?
Hello.
I am
currently learning Flask by going through this tutorial:
https://blog.miguelgrinberg.com/post/the-flask-meg...
read:
https://blog.miguelgrinberg.com/post/the-flask-meg...
The author of this tutorial uses SQLAlchemy ORM.
After reading it, it remained unclear:
1. What is migration, what exactly is it for and how does it relate to saving data?
2. How is migration different from db_upgrade or db_downgrade?
3. What will happen if migrations are not performed?
I didn’t find anything according to these links (I still don’t understand why I need them):
1. stackoverflow.com/questions/325882/Why-migrations are needed - Stack Overflow
2. Why are migrations necessary? -Toaster
Answer the question
In order to leave comments, you need to log in
1. What is migration, what exactly is it for and how does it relate to data retention?transition from one database structure to another without loss of consistency
2. How is migration different from db_upgrade or db_downgrade?migration implies both a direct change (upgrade) and a reverse change (downgrade)
3. What will happen if migrations are not performed?migrations can be omitted
DBMS can be divided into 2 groups:
Rigid DBMSs are faster and better optimized.
But they have a very unpleasant drawback - you cannot just start writing a new type of data there that was not provided for during the initial creation of the database.
The process of converting a database, in which the schema changes (tables and their columns; auxiliary things such as indexes, etc.) is called migration.
Moreover, an important point is that changes to the database structure can be made when it has existed for a long time and is filled with important information that cannot be lost, which further complicates the process.
And another important point:
As a rule, one or another version of the program is designed to work with either the old or the new database schema. Not at the same time with the old and the new. That is, before you start using the new version, you definitely need to migrate. And after you make the migration, it will no longer be possible to use the old version of the program. This further complicates the procedure for switching to a new version of the program.
I recommend that you familiarize yourself with a good manual on migrations in Django - perhaps this will bring you closer to understanding the essence of the process.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question