Avoid generating empty migrations on serialization failures
|Reported by:||Tim Graham||Owned by:|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
If a model fails to serialize, an empty migration file will be generated which needs to be removed manually. You'll get an error like "django.db.migrations.loader.BadMigrationError: Migration 0001_initial in app auth has no Migration class" if you try to migrate without doing so.
We should either verify that there won't be any errors before creating the migration file or remove the empty file if there is an error.