Database migrations

143 views
Skip to first unread message

ra...@hellofrom.amsterdam

unread,
Mar 4, 2016, 6:05:37 AM3/4/16
to Django users
Hi all,

I have been playing around with Django now for a couple of weeks

I have been adding apps to my project and one point of frustration is the migration. When there are PK and/or FK relations:
You are trying to add a non-nullable field 'user' to user without a default; we can't do that (the database needs something to populate existing rows).
Please select a fix:
 1) Provide a one-off default now (will be set on all existing rows)
 2) Quit, and let me add a default in models.py

What I'm use to do is DROP the database and migrate it again. I know this is not the way to go, because if you are doing this in PROD you will loose all your data. I don't get the logic behind this. Some of you must have experience with making major change to you PROD web application. How did you made sure all the data is preserved?

Cheers,
Raoul

Daniel Roseman

unread,
Mar 4, 2016, 2:21:12 PM3/4/16
to Django users
What are you expecting to happen? The message is quite clear, and offers the only two possible options. Are neither of those suitable? Why not? What other action would you like to take?
--
DR.
Reply all
Reply to author
Forward
0 new messages