Home / Companies / MongoDB / Blog / Post Details
Content Deep Dive

Building with Patterns: The Schema Versioning Pattern

Blog post from MongoDB

Post Details
Company
Date Published
Author
Daniel Coupal, Ken W. Alger
Word Count
1,069
Language
English
Hacker News Points
-
Summary

The Schema Versioning pattern in MongoDB allows for the easy updating of database schemas without downtime, making it ideal for situations where application downtime is not an option. This pattern utilizes MongoDB's support for polymorphic documents to store multiple versions of a schema in the same collection, with each version distinguished by a `schema_version` field. The pattern involves creating and saving new schema versions, which are then used by the application to handle different document types. With this approach, developers can better decide when and how data migrations will take place, resulting in less future technical debt and improved flexibility. The simplicity of the data model and the ability to combine with other patterns for extra performance make the Schema Versioning pattern particularly powerful in MongoDB.