Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP2universalStack: TypeScript / Sequelize
databaseenumdrysingle-source-of-truth
Derive ENUM column definitions from the enum's values
Define a database ENUM column from the TypeScript enum's values instead of hardcoding the option list, so the column and enum cannot drift apart.
PR: vinify-backend · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | @Column(DataType.ENUM('SOLD', 'BOUGHT', 'WASTED')) |
| 2 | activityType: string; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | @Column(DataType.ENUM(...(Object.values(CellarHistoryTypeEnum) as string[]))) |
| 2 | activityType: CellarHistoryTypeEnum; |
Explanation (EN)
Objašnjenje (HR)