🐛 Bound hours per week on settings

The field accepted any number from 0.01 up, so a typo or a bad client
could store more hours than a week has and break every expected value
derived from it. The initial migration limits hours_per_week to 168; no
database was ever deployed with the previous version of the migration.
This commit is contained in:
2026-12-01 16:54:32 +01:00
parent b41f83342c
commit 590758dfb6
4 changed files with 65 additions and 1 deletions
+2 -1
View File
@@ -80,7 +80,8 @@ func up(app core.App) error {
settingsHistory := syncedCollection("settings_history", users.Id,
&core.TextField{Name: "effective_from", Required: true, Pattern: dayKeyPattern},
&core.NumberField{Name: "hours_per_week", Min: types.Pointer(0.01)},
// 168 is the number of hours in a week.
&core.NumberField{Name: "hours_per_week", Min: types.Pointer(0.01), Max: types.Pointer(168.0)},
&core.NumberField{Name: "workdays_mask", OnlyInt: true, Min: types.Pointer(1.0), Max: types.Pointer(127.0)},
&core.TextField{Name: "timezone", Required: true, Max: 100},
)