sqlalchemy-bot / test_alembic_1

0 stars 0 forks source link

checkfirst feature ? #231

Open sqlalchemy-bot opened 9 years ago

sqlalchemy-bot commented 9 years ago

Migrated issue, originally created by Michael Bayer (zzzeek)

For making migrations "idempotent" for those working in online mode, and to expand upon #151, allow operations to run a "checkfirst" by using inspector.

#!python

op.add_column('myothertable', Column('foo', type), checkfirst=True)

Or another optional way it can be enabled, via context manager:

#!python

def upgrade():
    with op.checkfirst():
        op.create_table('mytable', <columns>)
        op.add_column('myothertable', Column(...))
        op.drop_column(...)

or even as a flag on EnvironmentContext. I think some will want all migration operations to include "checkfirst" where it is available.

"checkfirst" would be used all add_X / drop_X methods. It would not for the time being be used by alter_column(). The feature would work by building up an Inspector that will last for the lifetime of a single migration script, making use of the fact that results are cached, so if we want to check lots of add_column/drop_column, there'd only be one set of queries per table rather than query-per-column. The use contract would include that checkfirst is relative to the migration as a whole, and not relative to individual operations within the migration.

sqlalchemy-bot commented 9 years ago

Shatil Rafiullah (shatil) wrote:

I am following this feature with great interest :) Any idea what the timeline for it could be, @zzzeek? I would love to help, but am very unfamiliar with Alembic's code base.

sqlalchemy-bot commented 9 years ago

Michael Bayer (zzzeek) wrote:

I had no immediate plans to work on it, when i next get time to work on alembic I'll typically choose the things that people are needing the most. Haven't had much call for this one, I guess if you could round up some votes that would be something.

sqlalchemy-bot commented 9 years ago

Changes by Michael Bayer (zzzeek):

sqlalchemy-bot commented 9 years ago

Changes by Michael Bayer (zzzeek):

sqlalchemy-bot commented 9 years ago

Changes by Michael Bayer (zzzeek):