Set schema name while first migration #1272
-
Set schema name while first migration. Is there way to set what schema to use? Databases / Backends / Drivers targeted Example Use
Additional context |
Beta Was this translation helpful? Give feedback.
Answered by
zzzeek
Jul 13, 2023
Replies: 1 comment 1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
annndruha
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
step1: model is specific to a schema:
edit env.py here:
https://github.com/sqlalchemy/alembic/blob/main/alembic/templates/generic/env.py#L17-L21
set your model's
MetaData
there as described at https://alembic.sqlalchemy.org/en/latest/autogenerate.html#auto-generating-migrationsthen, in your model, set the schema name for each model, or the overall
MetaData
, as documented at https://docs.sqlalchemy.org/en/20/core/metadata.html#specifying-the-schema-name , as well as additional ORM-specific notes at https://docs.sqlalchemy.org/en/20/orm/declarative_tables.html#orm-declarative-table-schema-namestep2: have autogenerate look in other schemas; see https://alembic.sqlalchemy.org/en/latest/auto…