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 theassets 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:
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 sameassets use case, with both stream versions auto-subscribed and filtered by a schema_version connection parameter:
- Sync Streams
- Sync Rules (Legacy)