I have added a foreign key to a user to a model, but when I try to migrate the database using South, I get the following error:
_mysql_exceptions.OperationalError: (1067, "Invalid default value for 'user_id'")
South tells me that I may be able to recover from the error by running an SQL command:
! You *might* be able to recover with: =
ALTER TABLE `main_deal` DROP COLUMN `user_id` CASCADE; []
I tried to run the SQL command, but I get the following error:
#1091 - Can't DROP 'user_id'; check that column/key exists
Do I need to add 'user_id' to my model and set the default value to 1?
Edit: Here is the code that I added to my model to cause this to occur:
user = models.ForeignKey(User)
Then I migrated the model using South.