I have a postgresql database and I want to pass postgresql schema name in DSN, like this: postgresql://login:password@postgreshost/dbname?schema=my_schema
. I know that I can specify the schema
keyword in migration operations like op.create_table
. Unfortunately, upgrade()
and downgrade()
functions have no arguments in which I can pass postgres schema. Is there any way to pass schema name to op.create_table()
without hardcoding it?
Asked
Active
Viewed 943 times
2

Pehat
- 1,573
- 1
- 10
- 24
-
2Do you **always** want to use that schema as the "default schema"? Ify yes you could change the Postgres user: `alter user the_user set search_path = my_schema` to make all statements default to that schema – May 22 '18 at 13:25
-
1@a_horse_with_no_name, thank you, now everything works as I want. – Pehat May 22 '18 at 16:38
1 Answers
2
If that should always be the default schema, you can change the schema search path for the Postgres user:
alter user the_user set search_path = my_schema;
That will make all statements that use unqualified identifiers use my_schema
as the default.