0

I’m using alembic + sqlalchemy to manage a Postgres database. At the moment I have one single schema with a lot of table inside. I would like to organize tables based on their functions (table generated from csv importing, transformation tables, result tables) and my idea was to leverage on alembic to create at least 3 schemas. But from tables of one schema I need to create through sqlalchemy other tables to be stored in a different schema. Is it alembic the right package to do that? Could you please provide me with an example of the model? Each schema should contains different tables.

I tried to follow this example (https://elarkk.github.io/blog/multi-schema-sqlalchemy) but it didn’t work properly. It seems that alembic is not creating a valid schema.

1 Answers1

0

I suggest just using psql. Create the schema then use

alter table <table_name> set schema <new_schema_name>;

This will 'move' the table to the specified new schema.

Belayer
  • 13,578
  • 2
  • 11
  • 22