Support for SQL triggers

Issue #3474 wontfix
Konsta Vesterinen created an issue

The more complex my projects have become using SQLAlchemy the more I've used SQL triggers. It would be great if SQLAlchemy had builtin support for triggers. This would make it possible to:

  1. Have re-usable trigger code instead of ugly string based CREATE / DROP DDL statements
  2. Add later support in alembic for these triggers. My triggers have evolved greatly over time, thus it would be great if alembic noticed these changes automatically when issuing autogenerate.

Comments (5)

  1. Mike Bayer repo owner

    im pretty unenthused about adding this, having to support it, and constantly explaining/apologizing for the fact that triggers have entirely different capabilities and behaviors of which I myself have hardly any interest in. The sqlalchemy.ext.compiler extension was created so that I don't have to worry about these things and so that SQLAlchemy Core doesn't need to be plugged up with every possible SQL idiom.

    Why not build your own CreateTrigger/ DropTrigger system? Alembic is no problem, as it is now extensible also. Feel free to release a new library on Pypi for creating/altering triggers; the job of SQLA Core and Alembic is only to be extensible enough so that the specifics are maintainable by others on the outside.

  2. Mike Bayer repo owner

    that said I didn't yet propose a system for custom "compare" hooks in alembic autogenerate, that would be needed here also, that's what's worth working on on my end.

  3. Konsta Vesterinen reporter

    Ok that sounds good. I think custom compare hooks is exactly what I need most here. Thanks again, Mike!

  4. Log in to comment