recreate-migration: BASH Function to Recreate Migration
Django
2011-09-10 11:32 (14 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
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.
We look forward to discussing your development needs.