Skip to content

fix(migration): add the push broker schema to upgraded projects - #13859

Merged
ChiragAgg5k merged 2 commits into
mainfrom
fix/v25-push-ledger
Sep 23, 2026
Merged

ChiragAgg5k merged 2 commits into
mainfrom
fix/v25-push-ledger

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

migrate fails on every project upgraded from 2.2.0:

Migrating documents for collection "pushLedger"
Failed to migrate project "relproj" with error: Collection not found

pushLedger (the MQTT push broker's message ledger, #13372, renamed in #13815/#13848) is a new collection in app/config/collections/common.php, so it belongs to the console and to every project. New projects and the console database get it on creation, but nothing creates it for existing projects. V25 then iterates the configured collections in forEachDocument and throws on the missing table, which aborts the migration for that project.

V25 now creates pushLedger when it reaches it in migrateCollections, through the existing createCollection() helper, which is a no-op when the collection already exists, so re-running migrate stays idempotent.

The same PR added sequence, qos and expiry to topics without a migration, so upgraded projects had no such columns and the Appwrite push adapter's increaseDocumentAttribute('topics', $topic, 'sequence', 1) would fail on them. V25 now adds the three attributes to topics too.

Also removes a strtotime(null) deprecation in V25::predatesMigration() that the existing unit test triggered.

Found while running the 2.3.0 upgrade gate (2.2.0 install with seeded data → 2.3.0 image → migrate). Blocks 2.3.0; it needs to land on 2.3.x too (cherry-picked into #13857).

Test Plan

  • New unit test V25Test::testAddsPushBrokerSchemaToProjectFromPreviousRelease: a Memory-adapter database shaped like a 2.2.0 project (no pushLedger, no topic sequence/qos/expiry), runs V25 twice. Fails on main with Utopia\Database\Exception\NotFound: Collection not found, and with only the ledger fix on Failed asserting that an array contains 'sequence'; passes with both.
  • tests/unit/Migration: 17 tests pass, no deprecations.
  • PHPStan (level 4) and Pint clean on the changed files.
  • 2.2.0 install with seeded data → 2.3.0 image with this fix → migrate twice: both runs exit 0, _1_pushLedger and _1_topics.{sequence,qos,expiry} exist, seeded users, rows, files, topics and providers read back unchanged.

@ChiragAgg5k ChiragAgg5k changed the title fix(migration): create the push ledger collection for upgraded projects fix(migration): add the push broker schema to upgraded projects Sep 23, 2026
@greptile-apps

greptile-apps Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

The migration implementation appears correct, but the explicit repository requirement against implementation-coupled tests must be satisfied before merging.

Fix All in Claude CodeFindings

  1. P2 Test Mirrors Production Configuration ▶
Fix with agent prompt
### Issue 1
tests/unit/Migration/Version/V25Test.php:137-154
This test builds its 2.2.0 fixture from the current project collection configuration, then removes the exact `pushLedger`, `sequence`, `qos`, and `expiry` schema entries added by this migration. That violates the repository directive to test observable behavior without mirroring source configuration. It also makes future collections look as though they existed in 2.2.0, so the test could miss the same upgrade bug for them. Use an independently owned previous-release fixture and verify the resulting database behavior instead. This repository requirement must be satisfied before merging.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

This PR repairs V25 upgrades by creating the missing push-ledger collection before document migration, adds the push-broker topic attributes required by upgraded projects, and avoids passing null timestamps to strtotime.

  • Collection and attribute creation use the existing idempotent migration helpers.
  • The migration executes schema preparation before iterating collection documents.
  • The regression test exercises two consecutive migration runs, but its setup mirrors current production configuration and violates the repository’s testing requirement.

Reviews (1) · Last reviewed commit: "fix(migration): add the push broker topi..."

@github-actions

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/v25-push-ledger (after).

Metric Before After Change
🚀 Requests/sec 185.3 192.67 ⚪ +4%
⏱️ Latency P50 91.54 ms 89.38 ms ⚪ -2.4%
⏱️ Latency P95 222.09 ms 210.23 ms 🟢 -5.3%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 89.38 210.23 12,255 192.67 -11.86
Account 168.3 318.79 645 10.72 -23.26
TablesDB 86.19 169.3 6,665 107.68 -7.41
Storage 82.85 178.6 3,225 53.57 -10.05
Functions 128.49 246.83 1,720 29.15 -14.31

Top API waits (after)

API request Max wait (ms)
account.name.update 533.75
functions.variables.update 513.16
tablesdb.rows.get 441.24
account.prefs.update 432.94
storage.buckets.create 431.8

@ChiragAgg5k
ChiragAgg5k merged commit 7316872 into main Sep 23, 2026
97 of 98 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants