Upgrade Open Mercato to 0.6.4 (MikroORM 6 → 7)#72
Open
pat-lewczuk wants to merge 4 commits into
Open
Conversation
Bump all @open-mercato/* packages 0.4.8 → 0.6.4. The new framework
peer-depends on MikroORM 7, so @mikro-orm/* go 6.x → ^7.1.x and
@mikro-orm/decorators is added (newly required). react-is added as a
required peer of @open-mercato/ui.
MikroORM 7 moved decorators out of @mikro-orm/core, which broke
`yarn generate` ("does not provide an export named 'Entity'"). Migrate
the decorator imports in all app entity files to the framework's
documented path:
- import { Entity, PrimaryKey, ... } from '@mikro-orm/core'
+ import { Entity, PrimaryKey, ... } from '@mikro-orm/decorators/legacy'
Type-only imports (FilterQuery, EntityManager) and the Migration base
class are unaffected.
Verified: yarn generate (404 OpenAPI paths), db:migrate (all module
migrations applied), dev server boots and serves pages with no errors.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0.6.x introduced a generated `bootstrap-registrations.generated.ts` that registers backend/frontend route manifests into the shared module registry via `registerBackendRouteManifests()`. The admin sidebar nav API (`/api/auth/admin/nav`) builds the menu from `getBackendRouteManifests()`, which returns an empty array until those manifests are registered. The app's `src/bootstrap.ts` predates this step and never called `runBootstrapRegistrations()`, so the route manifest registry stayed empty (verified: 0 routes) and the sidebar rendered with no groups. Calling it at bootstrap module-eval populates the registry (verified: 205 backend routes across all core and app modules). bootstrap.ts is imported by the root layout and the `/api/[...slug]` catch-all (which serves the nav route), so the registry is populated in every request context that needs it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Beyond the route-manifest registration (sidebar fix), align src/bootstrap.ts with the canonical 0.6.4 app bootstrap, which had drifted since 0.4.x: - Apply modules.ts inline overrides via applyModuleOverridesFromEnabledModules() and register the AI domain applier (import '@open-mercato/ai-assistant'). - Register code-based workflow definitions via registerCodeWorkflows() — without this, code workflows are silently never registered. - Import modules from modules.app.generated (the app/widget-aware variant) rather than modules.generated. File now matches apps/mercato/src/bootstrap.ts at tag v0.6.4 exactly. Verified: app boots, /backend serves, no regressions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
MikroORM 7 removed knex entirely (em.getConnection().getKnex() no longer exists), breaking 25 raw cross-module queries across teams, competitions, judging, and the example module — they threw "getKnex is not a function" at runtime (team browse, chat, stats, invitations, check-in, etc.). knex cannot be reintroduced as a dependency: Turbopack statically traces knex's dialect loader and fails to bundle the uninstalled mysql/oracle/… drivers, which poisons the whole app bundle (no serverExternalPackages, resolveAlias, or runtime-require indirection avoids it). Migrate all usages to MikroORM 7's raw SQL via em.getConnection().execute(): - Add src/lib/db.ts helpers (rawAll/rawFirst/rawRun) used by API routes. - Subscribers can't import app-local files (their generator bundler doesn't resolve @/ or relative paths), so they inline the same execute() call. - Use `?` placeholders and `IN (?)` for array params (execute expands arrays knex-style; `= ANY(?)` would produce invalid SQL). All list call sites are guarded against empty arrays. - Also fixes two pre-existing bounties files that used the broken `= ANY(?)`. Verified: every affected route compiles and runs (401 when unauthenticated, no 500/hang), and the rewritten SQL executes against the database. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Upgrades all
@open-mercato/*packages 0.4.8 → 0.6.4 (latest stable). The new framework peer-depends on MikroORM 7, so this also bumps@mikro-orm/*from6.x → ^7.1.x, adds the now-required@mikro-orm/decorators, and addsreact-is(a required peer of@open-mercato/ui).Breaking change fixed
MikroORM 7 moved decorators out of
@mikro-orm/core, which brokeyarn generate(does not provide an export named 'Entity'). Migrated decorator imports in all 9 app entity files to the framework's documented path:Type-only imports (
FilterQuery,EntityManager) and theMigrationbase class are unaffected.Verification
yarn install— peers resolve (remaining warnings are transitive/optional, incl. disabledgateway-stripe)yarn generate— clean, 404 OpenAPI paths, no MikroORM cache warningyarn db:migrate— new 0.6.4 migrations applied (auth, customers, dictionaries, integrations, messages, query_index, staff, workflows)/&/login→ 200, all/backend/*→ 307 (auth redirect), no 500s / request errorsKnown follow-ups (not addressed here)
tsc/next buildOOM — the framework ships.ts-only types (no.d.ts), sotscdeep-checks the full framework source; combined with MikroORM 7's heavyFilterQuery/EntityManagergenerics it OOMs even at a 20GB heap.next dev(turbopack/SWC) is unaffected and runs fine. Best raised upstream; an app-side stopgap would betypescript.ignoreBuildErrorsfor builds.poll-githubqueue error — pre-existing WIP-feature bug (scheduled poll enqueues a job with no matching worker, which theclassify-prworker then crashes on). Not upgrade-related.🤖 Generated with Claude Code