我有一个 postgresql 数据库,我想在 DSN 中传递 postgresql 架构名称,如下所示:postgresql://login:password@postgreshost/dbname?schema=my_schema
。我知道我可以在 op.create_table
等迁移操作中指定 schema
关键字。不幸的是,upgrade() 和 downgrade() 函数没有可以传递 postgres 架构的参数。有没有办法将模式名称传递给 op.create_table()
而无需对其进行硬编码?
最佳答案
如果这应该始终成为默认架构,您可以更改 schema search path对于 Postgres 用户:
alter user the_user set search_path = my_schema;
这将使所有使用非限定标识符的语句使用 my_schema
作为默认值。
关于postgresql - 将 postgresql 模式传递给 alembic 迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50467928/