# Missing NOT NULL and uniqueness constraints in DB

**URL:** <https://meta.discourse.org/t/missing-not-null-and-uniqueness-constraints-in-db/125945>\
**Category:** Development\
**Created:** [16 באוגוסט,‏ 2019,‏ 3:53am UTC](https://meta.discourse.org/t/missing-not-null-and-uniqueness-constraints-in-db/125945 "2019-08-16T03:53:39Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Utsav](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/utsav/32/142741_2.png) [@Utsav](https://meta.discourse.org/u/Utsav)\
**Post date:** [16 באוגוסט,‏ 2019,‏ 3:53am UTC](https://meta.discourse.org/t/missing-not-null-and-uniqueness-constraints-in-db/125945/1 "2019-08-16T03:53:39Z")

</div>

Hi,

Wanted to make a report about a few validations/constraints that exist in models but are missing in DB.

#### Missing not null requirements

_PostDetail - key, value_ are required to be present in model but are nullable in DB.

1. Required in model (`app/models/post_detail.rb`):

#### Missing unique constraints

1. _TagGroup - name_. Unique in model (`app/models/tag_group.rb`)

2. Likewise, _WatchedWord - word_. (`app/models/watched_word.rb`)

3. Finally, _WebHookEventType - name_. (`app/models/web_hook_event_type.rb`):

Perhaps someone might be able to confirm if these seem reasonable. It’s possible they will help prevent a bug before it happens. Also, if so, the fix seems like it would be pretty straightforward, and I’m happy to create a pull request if that will be helpful.

Thanks.

---

_[View the full topic](https://meta.discourse.org/t/missing-not-null-and-uniqueness-constraints-in-db/125945)._
