Multiple Client Versions
In some cases, different client versions may need different output schemas.
When schema changes are additive, old clients would just ignore the new tables and columns, and no special handling is required. However, in some cases, the schema changes may be more drastic and may need separate sync rules based on the client version.
To distinguish between client versions, pass in additional
user_parameters
from the client to the PowerSync instance. Use these parameters to implement different logic based on the client version. Note: Support for this is not available in the Dart/Flutter SDK yet.Example to use different table names based on the client's schema_version:
# Client passes in: "user_parameters": {"schema_version": <version>}
assets_v1:
parameters: SELECT token_parameters.user_id AS user_id
WHERE user_parameters.schema_version = '1'
data:
- SELECT * FROM assets AS assets_v1 WHERE user_id = bucket.user_id
assets_v2:
parameters: SELECT token_parameters.user_id AS user_id
WHERE user_parameters.schema_version = '2'
data:
- SELECT * FROM assets AS assets_v2 WHERE user_id = bucket.user_id
Note that user parameters are not authenticated — the client can pass in any values. If the parameter must be authenticated, use
token_parameters
from the JWT instead.Last modified 1mo ago