Code review comment for lp:~rvb/maas/bug-1123986-db-filestorage-key

Revision history for this message
Raphaël Badin (rvb) wrote :

Thanks for the review.

> [1]
>
> +        db.add_column(u'maasserver_filestorage', 'key',
> +                      self.gf('django.db.models.fields.CharField')(default=u
> 'f8d320dc-79ba-11e2-9997-3c970e0e56dc', max_length=36),
> +                      keep_default=False)
> The default looks like it sneaked in.

Indeed, fixed (I've replaced it with ''). Note that it was of no consequence since the value of 'key' was changed right after this code.

> Although, what does keep_default=False do?

** South doc **
If keep_default is 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 this instance, Django itself will initialize the value so there is no need to set a default at the DB level. That would also make little sense because of the uniqueness of the column.

« Back to merge proposal