I have added a new field to my model to track the individual objects to users.
I then generated a migration using south and it asked me for a default value for this migration as the user field has no default value. I entered 1 as the id of the user. I am using sqlite as the db backend for development. Now when I open an sqlite shell and look at the db schema, the default value is still there:
CREATE TABLE "base_category" ("user_id" integer NOT NULL DEFAULT 1,
"id" integer PRIMARY KEY,
"name" varchar(80) NOT NULL);
However in the migration file it looks like this:
# Adding field 'TimeSlot.user'
db.add_column('base_timeslot', 'user',
self.gf('django.db.models.fields.related.ForeignKey')
(default=1, to=orm['auth.User']),
keep_default=False)
If I understood the south docs correctly, it should not be there:
If
keep_defaultis True, then any default value specified on the field will be added to the database schema for that column permanently. If not, then the default is only used when adding the column, and then dropped afterwards.
In other questions here on SO it was pointed out, that the default values are not handled on a db level, but in python instead.
finally my questions:
- Do I have to bother with the default value still in my db, as I do not need it anymore?
- Could it be an issue with sqlite, because I was not able to find out how to remove the default value manually using a SQL prompt?
It wasn’t considered a bug, but is now; South 0.7.7 (forthcoming as I write this) should fix it.