kvesteri / sqlalchemy-continuum

Versioning extension for SQLAlchemy.
BSD 3-Clause "New" or "Revised" License
575 stars 127 forks source link

Fix trigger creation during alembic migrations #209

Closed lyndsysimon closed 5 years ago

lyndsysimon commented 5 years ago

Alembic does not fire the after_create event during migrations, because alembic's create_table method dynamically creates its own SQLAlchemy Table instance upon which it run a create.

See this SO response by zzzeek for more information.

kvesteri commented 5 years ago

Thanks for the PR! :train:

lyndsysimon commented 5 years ago

No problem! I'm sorry about the failing tests; I was working on this for work, and had to put it aside for a while to work on more pressing issues. I'll get back to it in time if someone else doesn't take care of it in the meantime.

I'm also aware of another potential issue, but I've not yet had time to build a minimal reproduction of it. I believe there's an issue with string primary keys, or perhaps only if it's a string composite key. Postgres is complaining for me on a couple of tests (within our application) that the value is the wrong type - the value in question is '01', and it's being passed without quotes on an insert. Assuming I am able to get back to it (and I expect to), I'll nail down what's happening and fix it.

Thank you for writing SQLAlchemy-Continuum. Based on my research it seems to be the most mature package of its type and with a very clean and intuitive API to boot. The issues that I've had integrating it into our project are undoubtably due to it not yet being as widely adopted as it probably should be and because I'm integrating it into a large existing codebase with lots of corner cases.

Are you still interested in supporting it and encouraging adoption? If so, I'd be happy to help with documentation as well. One of the big stumbling blocks I've had is figuring out how to create and sync the tables and triggers, especially through Alembic. I've kept notes on that process so I'll be able to turn them into documentation if the need is there :)

kvesteri commented 5 years ago

I'm not actively developing this package anymore as our company is using PostgreSQL-Audit package for same purpose in our projects

lyndsysimon commented 5 years ago

Ah, OK. Any chance we could chat off-GitHub? Facebook Messenger is probably the easiest for me, here's my profile. Otherwise, my email is lyndsy@lyndsysimon.com.