django-pgtrigger
django-pgtrigger copied to clipboard
Feature request: MySQL support
@tomage leaving a placeholder here for MySQL support since it is actively under development.
So far it looks like MySQL support is going to be close to feature compliance with Postgres, with the following primary notes:
- Conditions aren't part of the trigger definition. Conditional logic on the old/new rows have to be placed inside the trigger function itself, making it a bit more difficult to make the
pgtrigger.Qandpgtrigger.Fobjects work as well. It should still be possible to make them completely compatible, but the first release of MySQL support may simply not have built-in condition support - In order to support
pgtrigger.ignore, we may need to makepg-connectioncompatible with MySQL so that we can hook into SQL generation and set temporary variables. Supportingpgtrigger.ignorewill almost certainly not be available in the first release of MySQL support - I have not researched much into statement-level triggers for MySQL. It is unclear what type of support will be available for this.
- MySQL does not support commenting directly on trigger objects, which is how pg-trigger maintains the hashes of installed triggers. We may need to insert a comment into the MySQL trigger definition to maintain its hash to know when the entire definition changes. Or we may need to rework how to detect trigger changes altogether. This is perhaps the most in-the-weeds change we have for MySQL support
It is likely that the support for MySQL and Postgres will be minimal enough that we can keep it in the same library. I am actively planning on renaming this to django-dbtrigger when we have close to full MySQL support.
Please thumbs up this feature request if you want it. It helps me prioritize my time when contributing to open source projects.
Hey everyone, update here.
I've recently added Django migration support to pgtrigger, which effectively solves number 4). The migration integration is still a bit of an experimental feature with a fallback to the old approach though. I'd still like to find a way to support the old approach
Number 2) from this issue is no longer a concern. pgtrigger now uses django's built-in DB hooks, making it easier to support pgtrigger.ignore for MySQL.