DT
Drizzle Team•14mo ago
Jim

enumerating tables

I have a table of possible 'statuses' for a column in my records table and would like my zod schema to see what statuses are available to set. Is this possible? I'm aware we can create an ENUM column on my records, but it 'feels' better to have a separate table for this. I guess I'm looking for an 'in-between' an enum column and a separate table. Maybe it's possible to predefine/lock-in the statuses in the application layer, is it bad practise? I'm new to db stuff so unsure on the best approach.
4 Replies
Angelelz
Angelelz•14mo ago
You could store the statusId on your records table that points to the status table where the statuses are. But if the statuses don't have any other meta information on them, I think an enum would be better
Jim
JimOP•14mo ago
Thanks! I've not used the enum column before so wary of using it. I'll give it a go. I was about to go the tables way and make a script which would validate the database prebuild. This would be a headache tbh so thanks for nudging me to the enums, fingers crossed.
Angelelz
Angelelz•14mo ago
It's great IMO, you'll have autocomplete on the statuses
Jim
JimOP•14mo ago
yeah it's exactly what i need 😂
Want results from more Discord servers?
Add your server