Database maintenance

This section is about solutions to keep your DB Sync framework up to date when major changes are done in the central database.

Large data changes

The application database may be subject of large data modifications, without changing the database schema structure.

To update your central data and automatically sync all remote databases, do the following steps:
  1. Shutdown/disable the DB Sync service (stop the GAS), to avoid DB Sync client apps to use the service.

  2. Perform the SQL changes in the central database.

  3. In the DB Sync user console, force a full sync/refresh, by resetting the last modification timestamp for every user/app/table.

  4. Restart/re-enable the DB Sync service (restart the GAS).

  5. On the next sync request from a remote DB Sync client app, the complete datasets will be re-transmitted to the client app in a regular synchronization process by using dbsync_app.data_sync(). Another option is to force the client app to ask for a complete db copy with dbsync_app.get_database_copy().

Note:

Regarding server-side applications using the DB Sync server-app API to register changes in SQL tables shared with the remote DB Sync client apps: If the DB Sync service is down, server applications can directly modify applications tables, without registering the changes, as long as you force a complete db copy or full sync.

Database schema changes

If the central database schema changes, the database schema for remote DB Sync database needs also to be updated, and the database schema definition for DB Sync needs to be updated and re-distributed to DB Sync client apps.

To modify the schema of your central data and automatically sync all remote databases, do the following steps:
  1. Shutdown or disable the DB Sync service (stop the GAS), to avoid DB Sync client apps to connect to the service.

  2. Perform the SQL database schema changes in the central database. The JSON schema definition file for DB Sync also needs to be updated with a new version number. Database schema changes typically require also code changes in the DB Sync client apps. For example, if a new column/field is added. This requires to re-build a new version of the DB Sync client app with the new database schema version, and force the users to update the app.

  3. When the new version of the DB Sync client app starts, force the app to do a complete db copy with dbsync_app.get_database_copy(), this will fetch the new database structure with fresh data.