For AI agents: a Markdown version of this page is at https://docs.snowplow.io/docs/fundamentals/schemas/versioning.md. The index of all documentation pages is at https://docs.snowplow.io/llms.txt, and the index for this section is at https://docs.snowplow.io/docs/cdi/llms.txt.
Versioning schemas
Every schema has a version, starting from 1-0-0. As your schema evolves, you will need to create new versions of it. All previous versions of a schema remain available to ensure backwards-compatibility.
Versioning has an important role in telling Snowplow Loaders how to handle the changes when loading into your data warehouse. For example, there may be a need to create new columns, update columns, or even create new tables.
It's important to understand when your change is breaking, and version correctly.
There are two kinds of schema changes:
- Non-breaking — a non-breaking change is backward compatible with historical data and increments the
patchversion (for example,1-0-0to1-0-1) or theminorversion (for example,1-0-0to1-1-0). - Breaking — a breaking change is not backward compatible with historical data and increments the
majorversion (for example,1-0-0to2-0-0).
Different data warehouses handle schema evolution slightly differently. Use the table below as a guide for incrementing the schema version appropriately.
| Redshift | Snowflake, BigQuery, Databricks | |
|---|---|---|
| Add / remove / rename an optional field | Non-breaking | Non-breaking |
| Add / remove / rename a required field | Breaking | Breaking |
| Change a field from optional to required | Breaking | Breaking |
| Change a field from required to optional | Breaking | Non-breaking |
| Change the type of an existing field | Breaking | Breaking |
| Change the size of an existing field | Non-breaking | Non-breaking |
In Redshift and Databricks, changing size may also mean type change. For example, changing the maximum integer from 30000 to 100000. See our documentation on how schemas translate to database types.
Changing a schema without incrementing the version has several risks:
- Events that were previously valid could become invalid against the new changes
- Your warehouse Loader, which updates the table according to the schema, could get stuck if it’s not possible to cast the data in the existing table column to the new definition (e.g. if you change a field type from a string to a number)
- Similarly, data models or other applications consuming the data downstream might not be able to deal with the changes
Aim to treat each schema version as immutable. If you can't avoid changing an existing schema version, you can fix it in one of two ways:
- Superseding: create a new, corrected version that replaces the incorrect version during validation. Use superseding for versions that are already in production.
- Patching: overwrite the existing version without changing its version number. Only patch versions that aren't in production yet.
For details, see Superseding and patching schemas.