Schema is ignored for table comparisons, but not for FK comparisons

Issue #370 closed
dieselmachine
created an issue

I have an issue where I run create_all, and then run alembic to detect changes (there should be none). Because the schema is ignored on the metadata-based FK, but preserved on the reflected FK, I get the following (i added a debug line in the sig check routine):

removed sig: ('tests', 'test', ('image_id',), 'test_schema', 'images', ('id',), None, None, 'not deferrable')

INFO:alembic.autogenerate.compare:Detected removed foreign key (image_id)(id) on table tests.test

added sig: ('tests', 'test', ('image_id',), None, 'images', ('id',), None, None, 'not deferrable')

INFO:alembic.autogenerate.compare:Detected added foreign key (logo_image_id)(id) on table whitelabels.whitelabel

Do I have something configured incorrectly? Is there something I can change to ensure the default schema is used when doing FK comparisons against tables in the default schema? The table in question does not have a hard-coded schema, so table.schema returns None.

Comments (2)

  1. Michael Bayer repo owner

    I don't see the word "postgresql" here, is that the case? You likely have some variant of confusion as a result of the behavior described at http://docs.sqlalchemy.org/en/rel_1_0/dialects/postgresql.html#remote-schema-table-introspection-and-postgresql-search-path.

    Can you:

    1. set your Postgresql search path to "public"

    2. specify the schema in all tables that are not in "public"

    3. remove the schema from all tables that are in "public"

    4. make sure you are using include_schemas: http://alembic.readthedocs.org/en/latest/api/runtime.html?highlight=include_schema#alembic.runtime.environment.EnvironmentContext.configure.params.include_schemas

    let me know if anything changes, or if this is not postgresql please provide more detail. thanks

  2. Log in to comment