Skip to content

Commit 93a33b5

Browse files
committed
fix: update schema hash on extension version change
When upgrading from an older version, the schema hash algorithm may differ. Call cloudsync_update_schema_hash before updating the stored version to ensure hash compatibility across synced devices.
1 parent 479c95d commit 93a33b5

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/cloudsync.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
extern "C" {
1919
#endif
2020

21-
#define CLOUDSYNC_VERSION "0.9.201"
21+
#define CLOUDSYNC_VERSION "0.9.202"
2222
#define CLOUDSYNC_MAX_TABLENAME_LEN 512
2323

2424
#define CLOUDSYNC_VALUE_NOTSET -1

src/postgresql/cloudsync_postgresql.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ static void cloudsync_pg_context_init (cloudsync_context *data) {
7373
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("An error occurred while trying to initialize context")));
7474
}
7575

76+
// update schema hash if upgrading from an older version
77+
if (dbutils_settings_check_version(data, NULL) != 0) {
78+
cloudsync_update_schema_hash(data);
79+
}
80+
7681
// make sure to update internal version to current version
7782
dbutils_settings_set_key_value(data, CLOUDSYNC_KEY_LIBVERSION, CLOUDSYNC_VERSION);
7883
}

src/sqlite/cloudsync_sqlite.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,6 +1459,11 @@ int dbsync_register_functions (sqlite3 *db, char **pzErrMsg) {
14591459
return SQLITE_ERROR;
14601460
}
14611461

1462+
// update schema hash if upgrading from an older version
1463+
if (dbutils_settings_check_version(data, NULL) != 0) {
1464+
cloudsync_update_schema_hash(data);
1465+
}
1466+
14621467
// make sure to update internal version to current version
14631468
dbutils_settings_set_key_value(data, CLOUDSYNC_KEY_LIBVERSION, CLOUDSYNC_VERSION);
14641469
}

0 commit comments

Comments
 (0)