-
-
Notifications
You must be signed in to change notification settings - Fork 299
Closed
Labels
Fast-TrackPrioritise this issue and release when resolved outside of release cyclePrioritise this issue and release when resolved outside of release cycleautogenerate - renderingbugSomething isn't workingSomething isn't working
Description
Migrated issue, originally created by Michael Bayer (@zzzeek)
@writer.rewrites(ops.CreateTableOp)
def create_table(context, revision, op):
return op
def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
connectable = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
with connectable.connect() as connection:
for schema_name in ['test_schema', 'test_schema_2']:
conn = connection
conn.execute("SET search_path TO %s" % schema_name)
context.configure(
connection=conn,
target_metadata=target_metadata,
upgrade_token="%s_upgrades" % schema_name,
downgrade_token="%s_downgrades" % schema_name,
process_revision_directives=writer,
x_schema_name=schema_name
)
with context.begin_transaction():
context.run_migrations(schema_name=schema_name)
because the upgradeops is visited multiple times, we get:
#!
File "foo/env.py", line 99, in <module>
run_migrations_online()
File "foo/env.py", line 94, in run_migrations_online
context.run_migrations(schema_name=schema_name)
File "<string>", line 8, in run_migrations
File "/home/classic/dev/alembic/alembic/runtime/environment.py", line 836, in run_migrations
self.get_context().run_migrations(**kw)
File "/home/classic/dev/alembic/alembic/runtime/migration.py", line 321, in run_migrations
for step in self._migrations_fn(heads, self):
File "/home/classic/dev/alembic/alembic/command.py", line 156, in retrieve_migrations
revision_context.run_autogenerate(rev, context)
File "/home/classic/dev/alembic/alembic/autogenerate/api.py", line 415, in run_autogenerate
self._run_environment(rev, migration_context, True)
File "/home/classic/dev/alembic/alembic/autogenerate/api.py", line 459, in _run_environment
hook(migration_context, rev, self.generated_revisions)
File "/home/classic/dev/alembic/alembic/autogenerate/rewriter.py", line 102, in __call__
self.process_revision_directives(context, revision, directives)
File "/home/classic/dev/alembic/alembic/autogenerate/rewriter.py", line 150, in process_revision_directives
self._traverse_list(context, revision, directives)
File "/home/classic/dev/alembic/alembic/autogenerate/rewriter.py", line 145, in _traverse_list
dest.extend(self._traverse_for(context, revision, directive))
File "/home/classic/dev/alembic/alembic/autogenerate/rewriter.py", line 139, in _traverse_for
traverser(self, context, revision, directive)
File "/home/classic/dev/alembic/alembic/autogenerate/rewriter.py", line 110, in _traverse_script
ret = self._traverse_for(context, revision, directive.upgrade_ops)
File "/home/classic/dev/alembic/alembic/operations/ops.py", line 1999, in upgrade_ops
"This MigrationScript instance has a multiple-entry "
ValueError: This MigrationScript instance has a multiple-entry list for UpgradeOps; please use the upgrade_ops_list attribute.
not sure how we can fix this because the traversal keeps happening repeatedly.
Metadata
Metadata
Assignees
Labels
Fast-TrackPrioritise this issue and release when resolved outside of release cyclePrioritise this issue and release when resolved outside of release cycleautogenerate - renderingbugSomething isn't workingSomething isn't working