feat(deploy): sync schema to replication subscribers before migrating

Logical replication carries rows but not DDL, so a migration that adds a
column stalls every subscriber with "missing replicated columns" until the
column exists there too. _prisma_migrations is replicated, so migrate deploy
on a subscriber reports nothing pending while its tables lag behind.

sync-replica-schema.sh applies pending migrations to each subscriber first,
tracking them locally in _replica_ddl_applied, then migrates the publisher.
--check reports subscription state and columns missing on any replica.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-11 21:34:02 +03:30
co-authored by Cursor
parent aec5e08a1e
commit 515e39d420
5 changed files with 206 additions and 1 deletions
+6
View File
@@ -0,0 +1,6 @@
# Copy to deploy/replicas.env on the publisher host (gitignored — holds passwords).
#
# Every logical-replication subscriber of superadmin_pub, space/comma/newline separated.
# The user must be able to run ALTER TABLE (table owner or superuser).
REPLICA_DSNS="postgresql://USER:PASSWORD@SLAVE_1_IP:5433/superadmin
postgresql://USER:PASSWORD@SLAVE_2_IP:5432/superadmin"