chore(migration): update migration files to enforce new publication mutation pattern

This commit is contained in:
Anish Sarkar 2026-05-12 17:31:49 +05:30
parent d923d34e38
commit c43bfdb1d9
5 changed files with 52 additions and 0 deletions

View file

@ -5,6 +5,17 @@ queries via Zero, instead of replicating all tables in public schema.
See: https://zero.rocicorp.dev/docs/zero-cache-config#app-publications
NOTE for future migration authors: this is the ONLY migration allowed
to use bare ``CREATE PUBLICATION``. All subsequent mutations of
``zero_publication`` MUST use the ``COMMENT ON PUBLICATION`` bookend
pattern wrapping an ``ALTER PUBLICATION ... SET TABLE`` -- copy the
``upgrade()`` function from migration
``143_force_zero_publication_resync.py`` as your starting template.
Raw ``DROP``/``CREATE PUBLICATION`` in new migrations would
re-introduce bug #1355 (zero-cache stuck on a stale replica snapshot
because Zero >= 1.0's change-streamer never sees the schema-change
event).
Revision ID: 116
Revises: 115
"""

View file

@ -17,6 +17,16 @@ IMPORTANT — before AND after running this migration:
3. Delete / reset the zero-cache data volume
4. Restart zero-cache (it will do a fresh initial sync)
DO NOT COPY THIS PATTERN. The ``DROP PUBLICATION`` + ``CREATE
PUBLICATION`` dance below is the pre-#1355 anti-pattern: on Zero >=
1.0 it does not reliably wake the zero-cache change-streamer and can
leave the replica pinned to a stale snapshot. This file is
grandfathered in because it has already shipped to users; new
publication mutations MUST use the ``COMMENT ON PUBLICATION`` bookend
pattern wrapping an ``ALTER PUBLICATION ... SET TABLE`` -- copy the
``upgrade()`` function from migration
``143_force_zero_publication_resync.py`` as your starting template.
Revision ID: 117
Revises: 116
"""

View file

@ -1,5 +1,16 @@
"""Add LOCAL_FOLDER_FILE document type, folder metadata, and document_versions table
DO NOT COPY THIS PATTERN. The bare ``ALTER PUBLICATION ... ADD/DROP
TABLE`` calls below pre-date the ``COMMENT ON PUBLICATION`` bookend
fix for bug #1355: on Zero >= 1.0 they do not reliably wake the
zero-cache change-streamer and can leave the replica pinned to a
stale snapshot. This file is grandfathered in because it has already
shipped to users; new publication mutations MUST use the
``COMMENT ON PUBLICATION`` bookend pattern wrapping an
``ALTER PUBLICATION ... SET TABLE`` -- copy the ``upgrade()`` function
from migration ``143_force_zero_publication_resync.py`` as your
starting template.
Revision ID: 118
Revises: 117
"""

View file

@ -21,6 +21,16 @@ IMPORTANT - before AND after running this migration:
3. Delete / reset the zero-cache data volume
4. Restart zero-cache (it will do a fresh initial sync)
DO NOT COPY THIS PATTERN. The ``DROP PUBLICATION`` + ``CREATE
PUBLICATION`` dance below is the pre-#1355 anti-pattern: on Zero >=
1.0 it does not reliably wake the zero-cache change-streamer and can
leave the replica pinned to a stale snapshot. This file is
grandfathered in because it has already shipped to users; new
publication mutations MUST use the ``COMMENT ON PUBLICATION`` bookend
pattern wrapping an ``ALTER PUBLICATION ... SET TABLE`` -- copy the
``upgrade()`` function from migration
``143_force_zero_publication_resync.py`` as your starting template.
Revision ID: 139
Revises: 138
"""

View file

@ -32,6 +32,16 @@ Skipping the zero-cache stop will deadlock at the ACCESS EXCLUSIVE LOCK on
"user". Skipping the data-volume reset will leave IndexedDB clients seeing
column-not-found errors from a stale catalog snapshot.
DO NOT COPY THIS PATTERN. The ``DROP PUBLICATION`` + ``CREATE
PUBLICATION`` dance below is the pre-#1355 anti-pattern: on Zero >=
1.0 it does not reliably wake the zero-cache change-streamer and can
leave the replica pinned to a stale snapshot. This file is
grandfathered in because it has already shipped to users; new
publication mutations MUST use the ``COMMENT ON PUBLICATION`` bookend
pattern wrapping an ``ALTER PUBLICATION ... SET TABLE`` -- copy the
``upgrade()`` function from migration
``143_force_zero_publication_resync.py`` as your starting template.
Revision ID: 140
Revises: 139
"""