I want to remove an app from a django project.
I want to remove
Running manage.py migrate app_to_remove zero
does not work:
django.db.migrations.migration.IrreversibleError:
Operation <RunPython <function forwards_func at 0x7ff76075d668>> in
fooapp.0007_add_bar is not reversible
I guess there are several migrations which are not reversible ...
To remove the app from your project, all you need to do is remove it from INSTALLED_APPS in your project's settings.py . Django will no longer load the app. If you no longer want the app's files hanging around, delete the app directory from your project directory or other location on your PYTHONPATH where it resides.
How do I delete all records in Django? If you want to remove all the data from all your tables, you might want to try the command python manage.py flush . This will delete all of the data in your tables, but the tables themselves will still exist.
Assuming you installed via "setup.py install" or equivalent, there is no special method; just delete the directories and any reference to the Django app in e.g. INSTALLED_APPS for any sites you want to keep.
Django's migration can be reset by cleaning all the migration files except __init__.py files under each project app directory, followed by dropping the database and creating migration again using python manage.py makemigrations and python manage.py migrate .
Note: this guide is successful with Django 3.1.1 and Python 3.8.2
Can you try this solution to clean your database and migrations first
manage.py makemigrations your_app
manage.py migrate
you can see the result in my example
python manage.py migrate --fake your_app zero
Check migrations:
python manage.py showmigrations
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With