tbicr / django-pg-zero-downtime-migrations

Django postgresql backend that apply migrations with respect to database locks
MIT License
525 stars 25 forks source link

fix deferred sql errors #51

Closed tbicr closed 9 months ago

tbicr commented 9 months ago

Fix for https://github.com/tbicr/django-pg-zero-downtime-migrations/issues/48

Internally django runs sql immediately or deferredly.

This lib rewrite standard sql and split some complex sql to two parts one of them go to immediate execution and second go to deferred execution. For example creation not null fields and unique constraints that require SHARE UPDATE EXCLUSIVE lock sql (deferred) that cannot to run together with ACCESS EXCLUSIVE lock sql (immediate) be safe.

As mostly constraints created deferred way it looks safe to preserve default django approach. However nice to keep option to switch approaches for a while.