Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hard coded 'alembic_version' in _produce_net_changes of autogenerate.py #77

Closed
sqlalchemy-bot opened this issue Oct 5, 2012 · 5 comments
Labels
autogenerate - detection bug Something isn't working

Comments

@sqlalchemy-bot
Copy link

Migrated issue, originally created by Christian Blume (@cblume)

Can we get rid of hard coded 'alembic_version' table name in _produce_net_changes() of autogenerate.py? This has implications for autogeneration of table migrations. Though, I am not sure how to fix this. Any ideas?

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

it would have to derive from the name given up in the Environment, shouldn't be hard. you can see the "# TODO" comment in _produce_net_changes() to that effect.

this unfortunately has no unit tests that affirm it either, would have to do that too:

#!diff

diff -r 03481917469dde2be467c352232cc38999c50507 alembic/autogenerate.py
--- a/alembic/autogenerate.py	Mon Oct 01 17:12:03 2012 -0400
+++ b/alembic/autogenerate.py	Fri Oct 05 10:41:33 2012 -0400
@@ -139,7 +139,9 @@
         'connection': connection,
         'dialect': connection.dialect,
         'context': context,
-        'opts': opts
+        'opts': opts,
+        'alembic_version': context._version.name,
+        'alembic_version_schema': context._version.schema
     }, connection
 
 def _indent(text):
@@ -156,7 +158,7 @@
                             include_symbol=None,
                             include_schemas=False):
     inspector = Inspector.from_engine(connection)
-    # TODO: not hardcode alembic_version here ?
+
     conn_table_names = set()
     if include_schemas:
         schemas = set(inspector.get_schema_names())
@@ -169,8 +171,11 @@
         schemas = [None]
 
     for s in schemas:
-        tables = set(inspector.get_table_names(schema=s)).\
-                difference(['alembic_version'])
+        tables = set(inspector.get_table_names(schema=s))
+
+        if s == autogen_context.get('alembic_version_schema'):
+            tables = tables.difference(
+                [autogen_context.get('alembic_version', 'alembic_version')])
         conn_table_names.update(zip([s] * len(tables), tables))
 
     metadata_table_names = OrderedSet([(table.schema, table.name)

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • added labels: autogenerate - detection

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

Issue #220 was marked as a duplicate of this issue.

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

9650ccf

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autogenerate - detection bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant