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
+3 -1
View File
@@ -34,7 +34,9 @@
"prisma:bulk-khanegi-modular-brand": "ts-node --transpile-only prisma/bulk-khanegi-modular-brand.ts",
"prisma:repair-khanegi-ui-config": "ts-node --transpile-only prisma/repair-khanegi-ui-config.ts",
"prisma:copy-sms-between-tenants": "ts-node --transpile-only prisma/copy-sms-between-tenants.ts",
"prisma:list-tenants": "ts-node --transpile-only prisma/list-tenants.ts"
"prisma:list-tenants": "ts-node --transpile-only prisma/list-tenants.ts",
"replicas:sync": "bash deploy/sync-replica-schema.sh",
"replicas:check": "bash deploy/sync-replica-schema.sh --check"
},
"prisma": {
"seed": "ts-node --transpile-only prisma/seed.ts"