Skip to content
Skip to main content

Part numbers are unique, and now the database agrees

· One min read
Marc Jeeves
Founder, Nexus PLM

Part numbers were generated from a per-type counter that could, under the right sequence of events, hand the same number to two objects.

{/* truncate */}

The generator was fixed, existing duplicates were renumbered, and a unique index was added so the database itself refuses to store a duplicate.

Application-level uniqueness checks are a good idea. A constraint in the database is the one that holds when something unexpected happens.