django-reset-migrations | Add one command to reset the django migrations | Data Migration library
kandi X-RAY | django-reset-migrations Summary
kandi X-RAY | django-reset-migrations Summary
Add one command to reset the django migrations. Sometimes you have one app that had a lot migrations in development process. And this migrations could be deleted, because anybody will need this in the future. Soo, could be stressfull delete the files, reset the database and create the first migration again ... to start to developer again and bla bla bla ... Because this, I made this command to reset the migrations and start the first migration. I hope be usefull to you 2 :D.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Delete all apps
- Delete dependences in migrations
- Delete a line from filename
- Delete migrations files
- Delete an app from the database
- Return the README file
django-reset-migrations Key Features
django-reset-migrations Examples and Code Snippets
Community Discussions
Trending Discussions on django-reset-migrations
QUESTION
I ran into an annoying issue today during the development of a Django project where I was attempting to move between a testing database and a development database, and I cannot seem to figure out a solid way to go about fixing issues with migrations.
Let's call my 'test' DB: testDB and my 'dev' DB: devDB
I was accessing testDB as usual through Django settings.py and I made migrations adding the clientID field you see in the code below.
Then, I decided to swap to devDB in my Django's settings.py to run python manage.py migrate, and my clientID field is not added to the new DB. When I run python manage.py makemigrations I get, as expected, "no changes detected".
Just so this is noted, I am using the django-reset-migrations package from PyPi after I make migrations so the migrations folder does not get complicated and everything is stored in a single 0001_initial.py migrations file.
I am not seeing a better way to handle this issue than by writing my own script that ensures all Model tables exist in whatever DB I am connected to, and that all Model fields are located in each table, else the table is altered and the appropriate columns are added, which brings me to my question...
If I use: python manage.py sqlmigrate objects 0001 (which is my 0001_initial.py file), I am presented with the creation code below:
...ANSWER
Answered 2018-Nov-16 at 10:53Just so this is noted, I am using the django-reset-migrations package from PyPi after I make migrations so the migrations folder does not get complicated and everything is stored in a single 0001_initial.py migrations file.
The solution to your problem is simple: stop doing this.
Resetting migration files in that way is an advanced, potentially dangerous technique. It's never required, but might be helpful in some circumstances. The migrations folder "getting complicated" is not a real problem that needs to be solved, especially for a beginning project.
What makes it dangerous is that, by design, it's erasing the history of changes made to your models and database. So if you run it when a database is not fully updated—as you've apparently done—you've deleted the information necessary to do so. (Specifically, when you reset the migrations before migrating your dev database you deleted the file that specifies how to add the new column.)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install django-reset-migrations
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page