Direct Answer
For small SpiceDB updates that only introduce new permissions, schema versioning (adding new relationship types) minimizes downtime. It preserves existing tuple semantics without requiring backfill or dual-write logic. Tuple migration is necessary only when re-defining existing types.
Why Schema Versioning Has Lower Downtime Impact
Adding a new relationship type to the schema does not alter the interpretation of existing tuples. The original type remains intact, so permission checks against legacy data continue to work immediately. No backfill is required because the data model for existing tuples does not change.
Key Behaviors
- Zookie consistency: Tokens remain valid across additive schema changes since no existing data is rewritten.
- Read availability: Unaffected—existing queries use unchanged types.
- Application changes: Required to reference the new type, but these can be deployed in parallel with the schema change.
When Tuple Migration Becomes Necessary
If you need to redefine an existing relationship type—for example, changing its valid permissions or cardinality—tuple migration is required. This typically involves:
- Creating a temporary new type
- Dual-writing tuples to both old and new types
- Migrating existing tuples (backfill)
- Switching reads to the new type
- Removing the old type
Downtime Risks with Tuple Migration
- Permission drift during dual-write if reads are not carefully routed
- Potential stale token issues if Zookie validation fails mid-migration
- Storage load spikes during backfill of large tuple sets
Recommended Steps for Zero-Downtime Schema Versioning
- Deploy new schema: Add the new relationship type using
spicedb schema update. This is a non-blocking operation.
- Update application: Deploy code that writes to the new type while still reading from the old type for existing data.
- Gradual migration: Over time, migrate reads to the new type for affected resources. No immediate backfill is needed.
- Cleanup: Once all reads use the new type, remove any fallback logic to the old type.
Verification and Safety Checks
Before deploying, test in staging:
- Run identical permission queries against old and new schemas to confirm unchanged results for existing tuples.
- Monitor SpiceDB logs for
stale token warnings during any dual-write simulation.
- Verify that Zookie tokens are correctly propagated after schema changes.
Uncertainty and Missing Detail
What is the scale of your tuple set? If you have millions of tuples and need to redefine an existing type, backfill time and storage impact become critical. The recommendation above assumes a small dataset where backfill completes quickly. For larger datasets, consider batching or offline migration strategies.