Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change database fields to NOT NULL #254

Open
Glutexo opened this issue May 5, 2019 · 0 comments
Open

Change database fields to NOT NULL #254

Glutexo opened this issue May 5, 2019 · 0 comments

Comments

@Glutexo
Copy link
Collaborator

Glutexo commented May 5, 2019

No host’s fields can ever be empty. Still they are declared as NULL. Let’s switch them to NOT NULL. This applies to:

  • account – no host can live without an account
  • display_name – defaults fo fqdn or id
  • created_on – filled in with a current timestamp
  • factsdefaults to an empty dictionary
  • tags – remove this field entirely
  • canonical facts – validated to be a dictionary with at least one item from a fixed set
  • system_profile_factsdefaults to an empty dictionary

I don’t think that we need any sophisticated validation logic in the database layer. The fields are still there with their type and nullability is a very basic property of the field. Moreover, non-nullable fields are more performant – faster to index and search. Not being able to insert a record without a value is in my eyes equally important as not being able to insert a value of a wrong type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant