In the documentation there is a mention of a reverse function in RunPython in django migrations https://docs.djangoproject.com/en/4.0/ref/migration-operations/#runpython When does the reverse function run? Is there a specific command to run the reverse function?
Both of the comments are correct. Each migration has a forward and backward command. When you are undoing migrations and running them backwards the reverse function will be used.
As mentioned you can reverse all migrations by specifying zero as the migration.
python manage.py migrate <app_name> zero
You can roll back to a specific migration by specifying a migration number
python manage.py migrate <app_name> 0016