Alembic - Use dates instead of revision #860
Replies: 3 comments 3 replies
-
+1 |
Beta Was this translation helpful? Give feedback.
-
hi there - I'm not sure I understand what this is asking for. you can use any revision identifier you'd like for a given revision by indicating the --rev-id argument to alembic revision:
if you'd like each revision to be fully independent of the others, then you give it a new head:
so that seems to be what you're asking for. but then, when you run "alembic upgrade", all these revs will be invoked in random order. Which seems to suggest perhaps you are looking for an alternative revisioning model that orders revisions strictly by timestamp and has no concept of a "down revision". if that's what you're looking for, that's not Alembic's model and you will need to implement your own solution. It's not generally a good assumption that the order of dependencies for database migrations has a 1-1 correlation to the specific timestamp that each was created, as different branches and merges may have been developed at interleaving times which dont correspond to the actual dependency chain for a database. |
Beta Was this translation helpful? Give feedback.
-
A few lines above suggest the OP is a development shop/agency, and is trying to merge multiple commits and revisions into consolidated changesets for client delivery. If so, that use-case isn't really supported within any database migration systems I've seen, and really should be done manually. I've managed projects in the past where people have used custom approaches like the one suggested, and it's never a problem until it is - and then it's a big problem that causes a few days of lost work. |
Beta Was this translation helpful? Give feedback.
-
I am facing conceptual difficulties in executing alembic based on the sequential revisions using modern delivery approaches.
Is your feature request related to a problem? Please describe.
We started to use delivery process based on GitFlow and almost every merge request is causing problems with alembic sequential revisions.
Ex:
Main DB has a revision 'A'
Ex: 3 Feature are developed on a separate branches and they are based on 'A'. Ex: 'A'->'B', 'A'->'C', 'A'->'D'
It's expected that developer will create a merge requests (GitFlow) and features will be automatically picked up, migration is started and feature is delivered.
For our project it's not a big deal if 'B','C','D' will be not strictly sequentially executed at the beginning while all 3 are based on the same release 'A' so it's suppose to be safe.
Now, with the revisions you need just a separate userstory to align all 3 features, so it's a manual step.
Describe the solution you'd like
To be honest I see it in a simpler way is just to make revisions based on date instead of the hash.
Please make a property just allowing to switch to the date and problem suppose to be gone.
In this case you also don't need to specify previous revision.
P.s. It can be used only for the particular usecase. For it's not a big deal if migration forward will be 'A' -> 'D', 'C', 'B' (based who delivered first)
and downgrade back will become sequential 'D' -> 'C' -> 'B'-> 'A' (based on date in alembic file)
Describe alternatives you've considered
Alternative is to manually merge features and files every time before the delivery that is really slowing us down.
Custom approach based on dates was used by me in a past and it was consistent.
Thank you for any suggestions.
Beta Was this translation helpful? Give feedback.
All reactions