recreate-migration: BASH Function to Recreate Migration
Django
2011-09-10 11:32 (15 years ago)

Rollback the migration, delete all migration scripts, and then redo the schema migrations.
※ To migrate to zero, all records in the database will be deleted.
Bash script
recreate-migration(){
if [ "$1" ]; then
./manage.py migrate $1 zero
rm $1/migrations/00??_*.py*
./manage.py schemamigration $1 --initial
./manage.py migrate $1
else
echo "usage: recreate-migration <app-name>"
fi
}
Please rate this article (No signup or login required)
Currently unrated
Related posts
Git Checkout Using Partial Branch Name Matching
Preventing "table already exists" error when canceling migrations in Django tests
Create a Full-Text Index in Migration Files with Django 1.7
When Updating Django from 1.6 to 2.0, django.db.utils.InternalError: (1364, "Field 'name' doesn't have a default value") Occurs During Migration
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.
We look forward to discussing your development needs.