Avoiding Keyboard Input for Removing Stale Content Types Automatically (migrations and automatic deployment)

64 views
Skip to first unread message

Proto

unread,
May 20, 2015, 10:22:45 PM5/20/15
to django...@googlegroups.com
I submitted this ticket recently: https://code.djangoproject.com/ticket/24820 

The content of it is as follows:

While removing models in one of my migrations, I was prompted by Django to input yes/no. For development, this is no problem. For automatic deployments it is.

I want to know if there exists or if it's possible to add functionality to Django to do this. I've created a modification which works, but also want to learn if anyone else has solved this problem differently.

Modifying the deployment file to include --noinput does not solve this problem (it basically defaults to no which ultimately doesn't remove the model).

The patch I've created seems to be working just fine. My solution involves editing the contenttypes to take an additional argument. The argument can be invoked inside a migration file so that I have full control over when it's used. You can view the code below.

Link to diff for the patch I created: ​https://github.com/Protosac/django/commit/d98fff8219469a363493e8d8455c7ffb2430d36f

The Django core team expressed interest in a solution that would address this problem, but rejected my specific implementation. I wanted to open a discussion to learn how other developers were dealing with this issue. 

Greg Shikhman

unread,
May 26, 2015, 7:19:04 AM5/26/15
to django...@googlegroups.com
Thanks for documenting your trouble, I ran into the same problem today. The kludge solution that I came up with was: 'yes yes | python manage.py migrate' in my deployment script -- decidedly suboptimal.

My preference would be for the yes/no decision of dropping stale models to be recorded within the migration itself at creation time, analogous to the choice of a backfill value a new column without a default value on existing rows. 
Reply all
Reply to author
Forward
0 new messages