Ensure new boolean fields on `application_settings` have a default

The following discussion from !2240 (merged) should be addressed:

  • @grzesiek started a discussion: (+2 comments)

    I recall having exactly the same problem numerous times already. What can we do to prevent it in the future?

What is the problem?

New application settings have two "defaults":

  • New install: When a record does not exist in application_settings, we use ApplicationSetting.defaults
  • On upgrade: When a record exists, the value defaults to the column default

What can be done?

  • Add a test that fails if a column exists on application_settings that does not have a default
  • This may require adding defaults to existing columns that don't have one. Or excluding them from the test

Optional?

  • Add a test that fails if a column exists on application_settings that is not listed in ApplicationSetting.defaults. I don't know if this is a problem that has happened before
  • Disallow null boolean fields in this table, to avoid 3 state booleans.

/cc @grzesiek @dblessing

Assignee Loading
Time tracking Loading