id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux 22788 Custom migration operations are rewritten incorrectly Matthew Schinckel nobody "I've written a custom migration operation, and was in the process of writing a management command to write a migration file, using the MigrationWriter class. It's almost all perfect, except that the MigrationWriter class assumes that the migration operation will be in django.db.migrations: https://github.com/django/django/blob/master/django/db/migrations/writer.py#L47 I suspect that the MigrationWriter will also be used for things like squashing migrations, so this problem may appear with custom migration operations then. I suggest that it should inspect the migration operation, and if it's not in the `django.db.migrations` module, add the relevant module to the imports, and use the correct path for the operation." Bug closed Migrations dev Normal fixed Accepted 1 0 0 0 0 0