merging old versions

16 views
Skip to first unread message

Chris Withers

unread,
Jun 20, 2019, 3:37:27 AM6/20/19
to sqlalchemy-alembic
Hi All,

I have some versions that make use of the third party package I no
longer use, how do I collapse down alembic revisions that have already
been executed everywhere?

I found
https://stackoverflow.com/questions/34491914/alembic-how-to-merge-all-revision-files-to-one-file
but that doesn't feel right...

Chris

Michael Merickel

unread,
Jun 20, 2019, 1:45:48 PM6/20/19
to sqlalchem...@googlegroups.com
I think the basic idea is to create a database and codebase in the state of the target revision. Then autogenerate a migration from nothing to that revision - just like you would do when starting to use alembic from an existing schema. From there you can change the slug on it so that it works as the down_revision of later migrations and clear out the old unused migrations that you're replacing.

- Michael

--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alem...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy-alembic/933cd6aa-0e35-8716-3725-56947157103b%40withers.org.
For more options, visit https://groups.google.com/d/optout.


--

Michael

Mike Bayer

unread,
Jun 20, 2019, 2:00:59 PM6/20/19
to sqlalchem...@googlegroups.com


On Thu, Jun 20, 2019, at 1:45 PM, Michael Merickel wrote:
I think the basic idea is to create a database and codebase in the state of the target revision. Then autogenerate a migration from nothing to that revision - just like you would do when starting to use alembic from an existing schema. From there you can change the slug on it so that it works as the down_revision of later migrations and clear out the old unused migrations that you're replacing.

- Michael

On Thu, Jun 20, 2019 at 2:37 AM Chris Withers <ch...@withers.org> wrote:
Hi All,

I have some versions that make use of the third party package I no
longer use, how do I collapse down alembic revisions that have already
been executed everywhere?

I found
but that doesn't feel right...


I think that's what the stackoverflow answer says too.     At the moment that might be the most expedient approach.   However I can see that Alembic might benefit from having a special option to autogenerate a model into Python code assuming no database to start with.    Feel free to propose though Alembic is suffering from lack of contributors right now.



Chris

--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alem...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Michael


--
You received this message because you are subscribed to the Google Groups "sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy-alem...@googlegroups.com.

Chris Withers

unread,
Jun 21, 2019, 2:09:46 AM6/21/19
to sqlalchem...@googlegroups.com
>> On Thu, Jun 20, 2019 at 2:37 AM Chris Withers <ch...@withers.org
>> <mailto:ch...@withers.org>> wrote:
>>
>> Hi All,
>>
>> I have some versions that make use of the third party package I no
>> longer use, how do I collapse down alembic revisions that have
>> already
>> been executed everywhere?
>>
>> I found
>>
https://stackoverflow.com/questions/34491914/alembic-how-to-merge-all-revision-files-to-one-file
>>
>> but that doesn't feel right...

On 20/06/2019 19:00, Mike Bayer wrote:
>
>> I think the basic idea is to create a database and codebase in the
>> state of the target revision. Then autogenerate a migration from
>> nothing to that revision - just like you would do when starting to use
>> alembic from an existing schema. From there you can change the slug on
>> it so that it works as the down_revision of later migrations and clear
>> out the old unused migrations that you're replacing.
>>
>> - Michael
>>
>
> I think that's what the stackoverflow answer says too.

Yep.

> At the moment
> that might be the most expedient approach.

Okay, TBH here the case is more that I have a couple of migrations that
use a package I want to remove as a dependency (sqlalchemy-searchable,
which is really good, fwiw, just turns out "like" querying is actually
going to work better for my needs), but I think I can just remove those
bits once all the migrations are run through...

> However I can see that
> Alembic might benefit from having a special option to autogenerate a
> model into Python code assuming no database to start with.    Feel free
> to propose though Alembic is suffering from lack of contributors right now.

Gotcha, I'll come with a PR rather just asking for something, but I'm
suffering from the same problem you are ;-)

thanks as always,

Chris
Reply all
Reply to author
Forward
0 new messages