Skip to main content
When schema changes are additive, old clients ignore the new tables and columns, and no special handling is required. More drastic changes, such as renaming tables or changing a table’s structure, can break older app versions that are still in use. In these cases, define separate versions of the affected Sync Streams so that each client version receives the tables and columns it expects.

Versioning by Stream Name

With Sync Streams, the most convenient approach is usually to define a new stream alongside the old one. New app versions subscribe to the new stream, while older app versions continue subscribing to the old one. For example, suppose a new app version changes the structure of the assets table in its client-side schema, defining it as assets_v2, while older app versions still define assets. Define a new stream alongside the existing one, using an alias to map the source assets table to the new client-side name:
Once the older app versions are no longer in use, remove the old stream from your configuration and deploy the change.

Versioning with Connection Parameters

Alternatively, clients can pass their version to the PowerSync Service as a connection parameter, and stream queries filter on it so each client only receives data for its version. This approach is useful when your streams are auto-subscribed: auto-subscribed streams sync to every client on connect, so clients cannot select a stream version by name. In legacy Sync Rules, connection parameters are called client parameters. The example below implements the same assets use case, with both stream versions auto-subscribed and filtered by a schema_version connection parameter:
Handle queries based on parameters set by the client with care. The client can send any value for these parameters, so it’s not a good place to do authorization. If the parameter must be authenticated, use parameters from the JWT instead.