Autogenerate doesn't issue a "CREATE SCHEMA" DDL #992
Replies: 2 comments 1 reply
-
hey there - There's not too much way to do this other than to implement the logic yourself. this is something that can be done but I'd have to work out an example for you. the notion of a "schema" is not very portable between different kinds of databases so it's not generally supportable. what sort of application is this where schemas are being added and dropped on a regular basis? if this is for multitenancy, usually that kind of thing is automated separately. |
Beta Was this translation helpful? Give feedback.
-
I was trying to achieve the same, and this answer from StackOverflow seems to do the job. |
Beta Was this translation helpful? Give feedback.
-
Hi all,
I'm using SQLAlchemy + Alembic in all my projects, mostly with PostgreSQL. When I use PG as a backend I tend to use schemas a lot. As in:
With a definition like this I would expect Alembic to generate an upgrade script like this:
However the "CREATE SCHEMA" statement is not automatically generated, I have to add it manually. No matter what I try to do, I cannot manage to get it there. The revision script is generated using
--autogenerate
at the command line and the db given to Alembic as a comparison is created from scratch (so obviously the schema is not already there).Any suggestion on how to get SCHEMAs managed by Alembic automatically?
Cheers.
Beta Was this translation helpful? Give feedback.
All reactions