[Pulp-dev] Required fields for models at the DB level

Fabricio Aguiar fabricio.aguiar at redhat.com
Mon Nov 18 20:13:51 UTC 2019

the best way that I found so far is this:
[image: image.png]4

Best regards,
Fabricio Aguiar
Software Engineer, Pulp Project
Red Hat Brazil - Latam <https://www.redhat.com/>
+55 11 999652368

On Mon, Nov 18, 2019 at 5:09 PM Tatiana Tereshchenko <ttereshc at redhat.com>

> I noticed that there is no enforcement at the DB level to require certain
> fields to be present on a model.
> I haven't checked all the field types but at least for TextField it's
> seems to be true.
> Even though `null` is False by default (`blank` as well), I can save a
> model instance without most of fields set.
> As an example, for UpdateRecord [0] in RPM plugin, plugin writer can do
> UpdateRecord().save() and it will be fine, all the fields are set to empty
> string :/ It wouldn't be possible to save it twice but it's due to the
> uniqueness constraints.
> In case plugin writer doesn't set properly all the required fields,
> bad/corrupted model instances will be silently saved in the DB and plugin
> can potentially have data migration issues later.
> Any suggestions how to handle that? Or do I miss anything?
> Tanya
> [0]
> https://github.com/pulp/pulp_rpm/blob/master/pulp_rpm/app/models.py#L440-L463
> _______________________________________________
> Pulp-dev mailing list
> Pulp-dev at redhat.com
> https://www.redhat.com/mailman/listinfo/pulp-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/pulp-dev/attachments/20191118/e26f5ed8/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 64987 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/pulp-dev/attachments/20191118/e26f5ed8/attachment.png>

More information about the Pulp-dev mailing list