Supabase Replication

What is Replication?

From the Supabase docs: “Replication is a technique for copying the data from one database to another”

How Logiak uses Replication

Logiak has two main uses for Replication -

1. Remote deployment

Logiak supports the remote deployment of new versions of a Project.

To understand what is meant by this, consider:

  • you have your users, and they are using a Logiak App you made
  • you notice that your App needs some changes. you make the changes and take a new version.
  • you deploy the new version

What we mean by “Remote deployment” here is that when you deploy the new version, you would like all devices to get notified, and let the users upgrade. You don’t want to always have to phone everyone, or send an email to everyone. Should be automatic.

Thanks to replication, it is.

  • At setup, we create a logiak_version table.
  • When you deploy a new version, a new row is created in the logiak_version table
  • If Replication is enabled for the logiak_version table, then
    • Supabase will automatically send a notification of the change in logiak_version.
    • Devices will download the version
    • Devices will show an upgrade button

2. Data sharing between devices

The second use Logiak Projects make of Replication is in data sharing between devices.

If Replication is turned on for all tables, not just logiak_version, then any database change on any device will be quickly reflected on all connected devices.

This is important for collaborative systems.

Synch reconciliation

This data sharing is magic, but it is not flawless. A device can lack connectivity when Supabase sends notification of a change and there is not a queue where such notifications are stored for each device until they are back online.

In a database application, where it is important to keep reasonably in sync with the master copy of the data, this can be a big negative.

With Logiak , we have implemented a corrective mechanism at Login:

At Login, if an Object has an auto-fill modified field, if there is connectivity, Logiak will check at the master (Supabase ) for all rows of the corresponding table whose modified date is later than the latest in the database on the device, and retrieve those records.