Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If redis is unavailable during migration, migration is applied but not inserted into migration table. #245

Open
yamac-kurtulus opened this issue Sep 9, 2023 · 0 comments

Comments

@yamac-kurtulus
Copy link
Contributor

What happened?

I was cloning my project to my laptop. I ran migrations and did not realise redis was not running and redis threw redis.exceptions.ConnectionError: Error -2 connecting to redis:6379. Name or service not known.

I started redis, and migrated again. This time finished with django.db.utils.ProgrammingError: relation "relation_name" already exists

Apparently if cachalot fails when performing cache invalidation during migrations, the exception is not handled gracefully and migration is not inserted into `django_migrations table.

What should've happened instead?

Either migration name should have been inserted into migration table and migration operation continued transparently, or migration should have been rolled back.

Steps to reproduce

  • create a django model
  • configure cachalot
  • make sure redis is not running
  • django-admin makemigrations
  • django-admin migrate see cache invalidation fails
  • start redis
  • django-admin migrate and migration fails because relation or model or field already exists.

Granted, I am using django 4.2.3, and redis 2.2.3, using django 4's built-in redis cache support, albeit officially supported. But I have seen in issues that it works. I did not have chance to try with other caches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant