Djongo - how to add custom migration using raw mongodb command

I have a legacy mongodb database. And I create a django application witch uses it. Djongo is used as a database provider. I want to add a custom update in my migration file:

db.collection1.updateMany({}, [{$set:{"field2": "$field1.id"}}])

I trid to add this command to migration file but it leads to an error:

 operations = [
        migrations.RunSQL("""
            update collection1
            set field2 = "$field1._id"
        """),
    ]

What is the correct way to add this command to migration?

Back to Top