2015-09-22 15:06 GMT-07:00 Mike Bayer <[email protected]>:

> OK, the only possible way this would happen is if "SELECT
> current_schema()" were returning the name "notifications", and I went back
> through our emails and found:
>
> 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']
>
> that is the issue.  If your search_path is set to only "public", then
> current_schema should *NOT* be reading "notifications"; per the docs (
> http://www.postgresql.org/docs/9.2/static/functions-info.html):
>
> current_schema returns the name of the schema that is first in the search
> path (or a null value if the search path is empty). This is the schema that
> will be used for any tables or other named objects that are created without
> specifying a target schema.
>
> So, is the username here the name "notifications"?    since this $user
> default is finding its way in there.
>
> I would do this when you connect:
>
> with engine.connect() as conn:
>     conn.execute("SET search_path='public'")
>

Yes, notifications is the name of the user AND the schema... not a
recommended practice I guess?

I set manually the search_path to only public as suggested, and prints
before and after show it during the revision:
...
INFO  [sqlalchemy.engine.base.Engine] show search_path
INFO  [sqlalchemy.engine.base.Engine] {}
('"$user",public',)
INFO  [sqlalchemy.engine.base.Engine] SET search_path='public'
INFO  [sqlalchemy.engine.base.Engine] {}
INFO  [sqlalchemy.engine.base.Engine] show search_path
INFO  [sqlalchemy.engine.base.Engine] {}
('public',)
...

Revision runs fine, but now when I run the upgrade it does not find the
alembic_version table (attached logs)... I suspect that the search_path is
restored so that it takes notifications again by default?

Would this issue be solved just by $user!=$schema, or is there something
else behind (as you were saying, not even $user should be on the search
path)?

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Attachment: revision.log
Description: Binary data

Attachment: upgrade.log
Description: Binary data

Reply via email to