recreate-migration: BASH Function to Recreate Migration

Django
2011-09-10 20:32 (13 years ago) ytyng

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
}
Currently unrated
The author runs the application development company Cyberneura.
We look forward to discussing your development needs.

Archive

2025
2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011