How do I delete the django cache database table?

115 Views Asked by At

I have been using django's database caching as shown here: https://docs.djangoproject.com/en/4.1/topics/cache/#database-caching

Recently I have migrated to redis caching, but I still have the cache table in my database from the command python manage.py createcachetable.

How can I safely delete this table?

1

There are 1 best solutions below

0
tarikki On BEST ANSWER

You can just create a custom empty migration with

./manage.py makemigrations --empty myApp

And then add raw SQL to drop the table.


from django.db import migrations


class Migration(migrations.Migration):
    dependencies = [
        ("myApp", "latest_migration"),
    ]

    operations = [
        migrations.RunSQL("DROP TABLE IF EXISTS cache_table_name;"),
    ]