Flask Migrate using different postgres schemas ( __table_args__ = {'schema': 'test_schema']})

前端 未结 1 1888
星月不相逢
星月不相逢 2021-01-20 22:35

I\'m trying to use flask, sqlalchemy, and flask_migrate...

But every time run manage.py migrate, alembic always detect my model as a new table.

I think that i pu

1条回答
  •  清酒与你
    2021-01-20 23:33

    Finally figured this out: there is an include_schemas option in configure that you have to set to True to force Alembic to scan all schemas before generating the migration.

    (Slightly) more details: http://alembic.zzzcomputing.com/en/latest/api/runtime.html#alembic.runtime.environment.EnvironmentContext.configure.params.include_schemas

    It's not completely clear to me why Alembic/Flask-Migrate was generating the migrations for tables in non default schemas without this option set in the first place... or rather, the fact that it would create migrations for non default schemas but not discover these tables in the DB is a surprising behavior.

    0 讨论(0)
提交回复
热议问题