How to Correctly Store Customer VAT IDs in PostgreSQL Without Losing Audit Trails
Many development teams store customer VAT IDs in a single mutable database column, which causes problems when auditors need to verify a customer's VAT status at a specific past date. The core mistake is conflating two distinct data types: the current VAT identifier, which can change, and the historical validation record, which must remain immutable. A more reliable schema separates these into two tables — one holding the latest identifier and another serving as an append-only log of validation checks. Developers must also normalize VAT IDs before storing them by uppercasing and stripping punctuation, while preserving country-specific prefixes like EL for Greece and XI for Northern Ireland. Enforcing strict regex validation at the storage layer is discouraged, as format rules vary by country and are better left to dedicated VAT validators.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in