share / share/sharedb

Lazy Schema Migration Possible in Middleware?

Open
#159 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
6.5k
Forks
456
Avg merge
1d 5h
Merged PRs (30d)
5

Description

I'm facing a scenario where I've added a new field to ShareDB documents ("schema" version 2), but older documents in the database don't have that field ("schema" version 1).

I'd like to perform schema migrations to documents when they get fetched or subscribed to - applying migration ops to the document before it reaches the client. Is this possible with ShareDB middleware?

My initial thought is that perhaps the 'doc' middleware action ("A snapshot was loaded from the database") can be used, but I'm not sure how to go about injecting ops such that the document gets transformed before reaching the client. Any ideas?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ShareDB's 'doc' middleware action, described as running when a snapshot is loaded from the database, and trace how that snapshot reaches a subscribed client. Determine whether migration operations can be applied at that entry point before delivery; done means documenting a supported approach or confirming that middleware cannot provide it.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend, databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.