How to use the MigrationAutodetector manually for dynamic models

Skip to first unread message

Diederik van der Boor

Aug 8, 2022, 11:00:35 AMAug 8
to Django users
Hi All,

I'm working on an API-server project that uses dynamically generated Django models, so it can service many user-provided datasets. To ease maintenance work, we'd like to generate the SQL statements to migrate database tables to a newer version of the schema. I've managed to use the internal Django migration API's for this.

Unfortunately, the call to migration.apply(old_state, schema_editor, collect_sql=True) breaks when there is more then one operation in the migration object. The ProjectState model fields get bound to a model, and therefore the next operation won't run.

Is there anything we're doing wrong? Or maybe we're using this migration API in ways that aren't foreseen in its design, but can be worked around?

Reply all
Reply to author
0 new messages