Improve data integrity by enumerating constants in the database #7981
Replies: 4 comments
-
@jonasraoni, are you proposing to have a set of constant tables, e.g. |
Beta Was this translation helpful? Give feedback.
-
Exactly, that's how I've been dealing with such hard coded enumerations/types. In general, I also prefer to use strings than numbers, so when a constant disappear I won't stay with holes, but it has some drawbacks. |
Beta Was this translation helpful? Give feedback.
-
I'm not convinced that adding constant tables in the database is going to improve things enough to justify the work. We'd need a lot of them in order to do this comprehensively -- roles, workflow stages, file stages, assoc types, etc. etc. There are a couple of other options we could consider:
We don't tend to run into data integrity problems with these in practice, so I think the issue is more around developer orientation. I'd like to avoid bikeshedding on this, though! It's way down our dev priority list and would take a lot of work to apply throughout. And a partial application is maybe worse than the original issue. |
Beta Was this translation helpful? Give feedback.
-
Yeah, I totally agree with the priority! I'm creating some issues just to share notes publicly/discuss, just a reminder for future cleanups. |
Beta Was this translation helpful? Give feedback.
-
Describe the problem you would like to solve
Several key fields in the database are related to hard coded constants in the code, which breaks the possibility of adding some integrity checks.
Describe the solution you'd like
submission.stage_id
,user_grous.role_id
, ...) have a properly linked entity in the database.name
/identifier
field to improve the debugging experience when filtering/listing data, also ensure the field has an unique key.Who is asking for this feature?
Developer
Beta Was this translation helpful? Give feedback.
All reactions