Renaming a Table on the Server

The approach here is to have the sync rules handle both the old and the new table name during the migration period.

Using maintenance mode on the backend here for simplicity. Other processes may be used to avoid maintenance mode, but that doesn't affect PowerSync system.

  1. Deploy sync rules containing both the old and the new table name, with a mapping (alias) from the new name to the old one (so that both end up with the old name on the client). This will cause validation errors because of a missing table, but PowerSync will still allow the deploy.

  2. Wait for sync rule reprocessing to complete.

  3. Put the backend in maintenance mode.

    1. i.e. Backend needs to be made unavailable to avoid breaking things during migrations.

  4. Apply the source schema changes (i.e. in Postgres database)

  5. Deploy backend changes and re-activate backend.

  6. Remove the old table from sync rules, then deploy and activate the sync rules.

Last updated