sqlalchemy / alembic

A database migrations tool for SQLAlchemy.
MIT License
2.76k stars 241 forks source link

Schema-Level Multi Tenancy for PostgreSQL Databases - Edge Case #1495

Closed biyani701 closed 3 months ago

biyani701 commented 3 months ago

In my models few tables need to be created in public schema and remaining tables in the specific schema Referencing https://alembic.sqlalchemy.org/en/latest/cookbook.html section "Rudimental Schema-Level Multi Tenancy for PostgreSQL Databases", in the first pass if i pass the schema first_schema, the tables are created

  1. in first_schema where model does not schema defined
  2. in public where schema = public is defined.

Now if i run the migration with second_schema, because the tables in public schema exists, the migration run fails,.

Is it possible to handle this by adding some hooks?

Databases / Backends / Drivers targeted

postgresql+psycopg2 **Example Use**

Additional context

Have a nice day!