alembic
alembic copied to clipboard
Record a history of when particular migrations were applied
Migrated issue, originally created by Josh Kupershmidt (@schmiddy)
I was a little surprised to see that the alembic_version table records only the current version_num, without even a timestamp indicating when that version was applied. For forensic purposes, it's often handy to know when past migrations were applied to a target database, e.g. when trying to track what happened to a database in the past, determine why some errors popped up in a production database around some time, etc. The alembic history command is useful, but not quite what I'm looking for, since it doesn't tell me when the migrations were actually run in production.
(I'm currently using alembic 0.6.7, but didn't see this feature requested or mentioned anywhere else, so am assuming the situation is the same in the bleeding edge.)
Michael Bayer (@zzzeek) wrote:
not a bad idea but the irony is that while we are all about migrating databases, changing the structure of the alembic_version table itself is tricky. Whether Alembic does it automatically when people upgrade or whether its some kind of option is a decision to be made. or if the structure of alembic_version itself is open ended and there's some kind of extension pattern to use.
Michael Bayer (@zzzeek) wrote:
maybe have this be enabled by a flag, "store_version_history", indicates the alembic_version table will be generated with additional columns up front. then have some other system for people who want to move an existing alembic_version table.
or we have a separate table for history. still might be something we enable w/ a flag though - all the issues, what schema is the table within, what is it named, etc., all that happens again. a separate table at least can show the status of versions that are no longer the current head version.
just a note, I think separate auditing table would be much easier to implement and also it should be enabled via an option to suit environments that don't currently have such a table present.
See https://github.com/jpassaro/Audit-Alembic for an example of how this could be done. It would be nice to update and absorb this project into Alembic proper.
Hi,
Do we any news for this?
I think this would be an awesome feature to have. The mechanism is proved to work well by Sequelize :)
I am a newbie to database version control and have looked into flyway (java), yoyo-migrations (python) and finally alembic (python).
As a heavy python user, I would love to do everything in python. However, the lack of alembic_version_history table really makes auditing difficult.
It would be great to see it implemented like in flyway and yoyo-migrations!
good idea at #1075, record the first line of the "message" also.
Anything new around this?
you'd see it here first
an additional use case that may make use of this feature could be the one mentioned in #1298