-1

After refactoring some models in a bloated app (everything in appname/models.py) into a subfolder application (some of the models in appname/subapp/models.py) and running makemigrations, I'm getting the following error when running manage.py migrate:

ValueError: Found wrong number (2) of constraints for   appname_modelname1(modelname2_id)

Getting rid of all migrations and starting over would be one option, but then I'd have to manually edit all existing production databases. Are there any alternatives to make the migrations apply smoothly?

andyn
  • 577
  • 1
  • 6
  • 18

1 Answers1

1

Turns out that ./manage.py makemigrations makes overly complex migrations that will likely fail on a real constraint-enforcing database. If the objective is just to get rid of models, first make the migrations, then edit the migration file so that only the RemoveModel directives remain, and finally apply the migrations.

andyn
  • 577
  • 1
  • 6
  • 18