In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "django's migrations file reset management method". In the daily operation, I believe that many people have doubts about django's migrations file reset management method. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "django migrations file reset management method". Next, please follow the editor to study!
When using django to develop a project, if you use the model model to manage your database tables, you will be familiar with the migrations file. Every time there are new changes to the model model, you will execute the python manage.py makemigrations command to generate some migrations script files that manipulate the data table. But as the project iterates, the data table will certainly change more and more, and your migrations files will become more and more, such as this:
If you delete these files directly, there will be an error the next time you execute the makemigrations command, because multiple migrations files are related.
But django provides a solution for managing migrations files
1. By executing python manage.py migrate-fake zero, you can reset the migrations file under the corresponding app, that is, automatically clear the execution record of the migrations file under the app
two。 Delete the migrations file under the corresponding app
3. Execute python manage.py makemigrations to regenerate the migrations file
4. The python manage.py migrate-fake is then executed to record the migrate execution record in the migrations table in the database, but the code in the migrations file is not executed.
This makes it possible to reset migraion files without making changes to the existing database, and mom doesn't have to see a push of files in the migration folder anymore.
Note: the command python manage.py migrate-fake-inital is for all app operations
At this point, the study on "django's migrations file reset management method" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.