From 96d4c66a05c8b3bd6e6235a8077d6d6200d6684f Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Thu, 30 Jul 2026 19:07:08 +0200 Subject: [PATCH 1/4] Remove the weight_weightentry from the sync rules Weight is not tracked via the measurements --- services/config-powersync/sync_rules.yaml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/services/config-powersync/sync_rules.yaml b/services/config-powersync/sync_rules.yaml index 9cda29414..a9e1bd998 100644 --- a/services/config-powersync/sync_rules.yaml +++ b/services/config-powersync/sync_rules.yaml @@ -83,14 +83,8 @@ streams: # Routines (templates excluded) - SELECT * FROM manager_routine WHERE CAST(user_id AS TEXT) = auth.user_id() AND is_template = FALSE - # Measurements + # Measurement categories (the measurements themselves are HOT, see below) - SELECT * FROM measurements_category WHERE CAST(user_id AS TEXT) = auth.user_id() - - | - SELECT measurements_measurement.* - FROM measurements_measurement - INNER JOIN measurements_category - ON measurements_measurement.category_id = measurements_category.id - WHERE CAST(measurements_category.user_id AS TEXT) = auth.user_id() # Nutrition plan structure (not the log items) - SELECT * FROM nutrition_nutritionplan WHERE CAST(user_id AS TEXT) = auth.user_id() @@ -115,8 +109,13 @@ streams: user_activity: auto_subscribe: true queries: - # Weight tracking - - SELECT uuid AS id, weight, date, user_id FROM weight_weightentry WHERE CAST(user_id AS TEXT) = auth.user_id() + # Measurements, including body weight entries, so typically one or more new rows per day + - | + SELECT measurements_measurement.* + FROM measurements_measurement + INNER JOIN measurements_category + ON measurements_measurement.category_id = measurements_category.id + WHERE CAST(measurements_category.user_id AS TEXT) = auth.user_id() # Workout sessions and per-set logs - SELECT * FROM manager_workoutsession WHERE CAST(user_id AS TEXT) = auth.user_id() From 2b1b61051d078d4ae13b6b678c01fd9088490448 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Sun, 9 Aug 2026 15:55:05 +0200 Subject: [PATCH 2/4] Add comment describing when powersync re-evaluates and re-syncs the buckets --- services/config-powersync/sync_rules.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/config-powersync/sync_rules.yaml b/services/config-powersync/sync_rules.yaml index a9e1bd998..f064bd2ce 100644 --- a/services/config-powersync/sync_rules.yaml +++ b/services/config-powersync/sync_rules.yaml @@ -1,5 +1,13 @@ # Note that changes to this file are not watched. # The service needs to be restarted for changes to take effect. +# +# A column added server-side does not reach rows already in bucket storage: +# the queries below (SELECT * included) only run when a row is replicated, and +# an AddField emits no WAL. After such a migration either run a backfill that +# touches the rows, or bump the version line below so the changed file forces +# a reprocess +# +# Sync rules version: 1 # Warning: a user may have at most 1000 buckets, i.e. parameter-query results # summed across all streams. This counts the *parameter* rows, not the data From a92e185e0fc4b9b066ee632e4bd50db44c17d262 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Fri, 21 Aug 2026 15:42:25 +0200 Subject: [PATCH 3/4] Mention explicitly adding new tables to the publication --- services/config-powersync/sync_rules.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/config-powersync/sync_rules.yaml b/services/config-powersync/sync_rules.yaml index f064bd2ce..ca616e27b 100644 --- a/services/config-powersync/sync_rules.yaml +++ b/services/config-powersync/sync_rules.yaml @@ -9,6 +9,11 @@ # # Sync rules version: 1 +# Every table referenced here must be part of the "powersync" publication, which +# lists its tables explicitly (see the server's core migration 0027). Reading from +# a table that was not synced before also needs +# `ALTER PUBLICATION powersync ADD TABLE ;` + # Warning: a user may have at most 1000 buckets, i.e. parameter-query results # summed across all streams. This counts the *parameter* rows, not the data # rows inside a bucket (a single bucket can hold any number of rows). For a From 77fad3d9fae7180ce1ac132f4d5ed4cc30a8c20e Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Fri, 21 Aug 2026 15:43:30 +0200 Subject: [PATCH 4/4] Further increase the max parameters, just to be safe --- services/config-powersync/powersync.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/config-powersync/powersync.yaml b/services/config-powersync/powersync.yaml index 8c4f2d6ab..a5c2b0b2b 100644 --- a/services/config-powersync/powersync.yaml +++ b/services/config-powersync/powersync.yaml @@ -65,7 +65,7 @@ port: !env PS_PORT # https://github.com/wger-project/flutter/issues/1237 api: parameters: - max_parameter_query_results: 2000 + max_parameter_query_results: 10000 # Specify sync rules sync_rules: