On 9/21/15 8:14 PM, Sergi Pons Freixes wrote:

2015-09-21 16:55 GMT-07:00 Mike Bayer <mike...@zzzcomputing.com <mailto:mike...@zzzcomputing.com>>:

    Can you run the above with logging enabled?  That is the [alembic]
    logger turned on as in the default alembic.ini.


Sure thing, this was the output:

$ alembic -c development.ini revision -m "upgrade" --autogenerate
('"$user",public',)
INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO  [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.ddl.postgresql] Detected sequence named 't2_id_seq' as owned by integer column 't2(id)', assuming SERIAL and omitting INFO [alembic.autogenerate.compare] Detected removed foreign key (t1id)(id) on table t2 INFO [alembic.autogenerate.compare] Detected added foreign key (t1id)(id) on table notifications.t2
  Generating
XXX/notifications/scripts/alembic/versions/3e56f486dde_upgrade.py ... done

OK great, I can now show something similar happening. Your model has tables t1 and t2 in *both* the public and notifications schema and I'm assuming the same foreign key setup.

In many of your examples I've observed the explicit use of "public":

        __table_args__ = {'schema': 'public'}

That has to be removed entirely. When I have all four tables and I use "public" explicitly, the reflection system cannot get enough information to make a decision, based on the information in the section I originally referred to at http://docs.sqlalchemy.org/en/rel_1_0/dialects/postgresql.html#remote-schema-table-introspection-and-postgresql-search-path - see the yellow sidebar box at the bottom of the section for a quick summary.

When I remove the redundant "public" schema from my table defs, the redundant FK defs go away.





With the logger config:

# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARN
handlers = console
qualname =

[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine

[logger_alembic]
level = INFO
handlers =
qualname = alembic

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S


    Also, can you please run this script with your database URL and
    send me the full output, with any sensitive information omitted:

    from sqlalchemy import inspect, create_engine

    e = create_engine("postgresql://scott:tiger@localhost/test")

    inspector = inspect(e)

    print "default schema:", inspector.bind.dialect.default_schema_name
    print "schema names:", inspector.get_schema_names()
    print "dflt table names:", inspector.get_table_names()
    print "notifications table names:",
    inspector.get_table_names('notifications')


The output of the script is:
$ python inspector_test.py
default schema: notifications
schema names: ['information_schema', 'notifications', 'public']
dflt table names: ['alembic_version', 't1', 't2']
notifications table names: ['alembic_version', 't1', 't2']
--
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-alembic+unsubscr...@googlegroups.com <mailto:sqlalchemy-alembic+unsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

--
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-alembic+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to