Configurable default schema & replica id #83
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Configurable default schema
Let the replicator module specify the default schema, instead of using a
DEFAULT_SCHEMA
const.For postgres the 'public' schema is easy. However, for other source databases such as mysql or mongodb, we want to use the database from the connection string as the default, while possibly allowing other databases to be explicitly specified.
Flexible replication id
Let the replicator module compute the replica id for each operation, instead of auto-computing. This can now be persisted as any BSON-compatible value, instead of always converted to a v5 UUID.
Currently, for Postgres, we compute the replica identity as a hash (v5 uuid) from all replica identity columns, after converting to the SQLite format. However, we want the replica identity behavior to match the source database as close as possible, and we lose precision in this way. For example, the old approach would consider
_id: ObjectId('66e834cc91d805df11fa0ecb')
and_id: '66e834cc91d805df11fa0ecb'
as equivalent, while MongoDB considers those as distinct ids. So the new approach allows any BSON-compatible value to be used, and the replicator module can decide what to use.This does not change anything for Postgres yet.
Implementation notes
SyncRulesBucketStorage
instances (BucketStorageFactory.getInstance()
) doesn't include a parsed copy of sync rules by default. It is parsed onstartBatch()
instead, or by callinggetParsedSyncRules()
. This affects some other APIs as well.<table>/<replica id>
. We may migrate the Postgres ones to the new smaller format as well in the future.