Open Pritish053 opened 3 months ago
For newer version of fastapi that >= 0.100, should use lifespan instead: https://github.com/tortoise/tortoise-orm/blob/develop/examples/fastapi/main.py
Otherwise, init_db
and register_tortoise
do the same action, remove one of them.
Hey @waketzheng Thanks for the input but still it doesn't create the table inside the non-public schema. tortoise.exceptions.OperationalError: relation "pgdev.names" does not exist
Hi!
It is indeed doesn't work, mostly because no one developed it to do so
schema param was added just to solve compatibility issue (mostly with oracle iirc), and it didn't go further than that
As workaround - if you are working with postgres - you can modify search_path
for your pg user, but it is obviously limited solution if you want to work with several overlapping schemas simultaneously
Or you can look into contributing to tortoise to improve schema handling
Run into the same issue, even debugged into BaseSchemaGenerator code to discover _meta.schema is being ignored whatsoever.
Willing to contribute to code, will contact you if I make any progress.
Tried to create a pull request today but I need permissions to do so.
Usually you do it by pushing changes to your fork and then creating PR from your fork
Doesn't it work like that for you?
Created pull request. Even thou I sense there is additional work to do.
Describe the bug Tortoise ORM has issues generating schemas when a specific schema other than the default public schema is specified. When attempting to use a schema other than public, the ORM does not create the tables automatically.
To Reproduce
Expected behavior The names table should be created within the pgdev schema, and the record should be inserted successfully.
Actual behaviour tortoise.exceptions.OperationalError: relation "pgdev.names" does not exist
Environment