Recreating Tables for a Specific Django App

Recreating Tables for a Specific Django App: To delete a table from a specific app in Django, follow these steps: Firstly, let’s get rid of the migration folder for that particular app you have in mind.

Now, execute the following command:

python manage.py dbshell

After running the above command, use the following command within the dbshell to delete the desired table from migrations:

DELETE FROM django_migrations WHERE app = 'app_name';

Exit the dbshell (ctrl+c), then run the following command to generate new migrations:

python manage.py makemigrations app_name

Finally, execute the following command to recreate the table you’re interested in:

python manage.py migrate

And there you have it!


Tags: