I’m working with data migrations in django, and at some point, I’ll have to run migrations.RunPython. The point is that I wish I could execute migrations operations(AddField, AlterField) under certain conditions.
For example:
def forward_migration(apps, schema_editor):
if some_condition:
migrations.AddField(...)
class Migration(migrations.Migration):
dependencies = [
('some_app', '0002_auto_...'),
]
operations = [
migrations.RunPython(forward_migration)
Thanks in advance.
2