Skip to content

Latest commit

 

History

History
17 lines (12 loc) · 707 Bytes

Patterns.md

File metadata and controls

17 lines (12 loc) · 707 Bytes

Patterns

UUID

All models in the app are using UUID (generated by postgres: gen_random_uuid() from pgcrypto extension) instead of traditional sequential ids.

Benefits:

  • for distributed systems gain ability to assign primary key values without collisions
  • unable to guess records just by incrementing/decrementing ids or to get some insights on how big is the dataset
  • prevents from typos as UUID needs to be the exact value

Dark side:

  • hard to communicate them without copy/paste - don't try to say them
  • rows are sorted randomly so without created_at you can't tell the order
  • more memory cause it's bigger than just integers

Setup: https://github.com/dmp0x7c5/travel-blog/pull/4/files