MemberJunction / MemberJunction/MJ

`mj app install` tells the operator to run CodeGen for a schema it just excluded from CodeGen

Open Beginner friendly
#4,238 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TSQL
Stars
29
Forks
6
Avg merge
2d 1h
Merged PRs (30d)
323

Description

`mj app install` finishes a schema-bearing Open App install by telling the operator to run `mj codegen`. Earlier in that same install it added the app's schema to the host's `excludeSchemas`, so the host's CodeGen will skip it. An operator who follows the advice sees nothing happen and has no way to tell why.

## The two sites

`packages/OpenApp/Engine/src/install/install-orchestrator.ts:500`:

```ts
summary = `App installed. Its schema and tables exist, but entity metadata is generated by CodeGen — run 'mj codegen', then restart MJAPI and rebuild MJExplorer to activate.`;
```

`packages/OpenApp/Engine/src/install/install-orchestrator.ts:1980-1983`, inside `HandleServerConfig`, which the install calls at line 410 — before the summary is composed:

```ts
// Add app schema to excludeSchemas so CodeGen skips entity discovery,
// view generation, and Angular component generation for app-owned tables
if (manifest.schema?.name) {
const excludeResult = AddExcludeSchema(context.RepoRoot, manifest.schema.name, context.ServerPackagePath);
```

Both run in the same install, in that order, so the advice is unreachable by construction.

## Which one is right

The exclusion is. `plans/open-app-spec.md:387` states the intended model:

> The app author is responsible for including **all database objects** in their migrations — tables, stored procedures, views, and any other DDL. Unlike MJ core development where CodeGen generates sprocs and views, app migrations must be self-contained because CodeGen does not run on app schemas at install time.

and `:393-396` restates it as a property of the install:

> - The consumer's `mj codegen` will skip all schemas belonging to installed Open Apps
> - App authors publish their own generated entity classes as part of their npm packages

So an Open App's entity metadata arrives through its **migrations**, and its generated entity classes through its **npm packages**. Neither needs the host's CodeGen. The remaining step after install really is just restart + rebuild — which is exactly what the non-schema branch of that same `if` already says.

## Why it is worth fixing rather than ignoring

The message is actively misleading in the one situation where an operator is already unsure. If an app's entities do not appear, the true cause is almost always that the app shipped a migration without its CodeGen output — the app's own bug — but this message sends the operator to re-run CodeGen on the host instead, which cannot help and will not error. The comment at `:495` ("Tell the operator to run CodeGen FIRST for schema apps (B16)") suggests the message predates the `excludeSchemas` behaviour and was never revisited.

## Suggested wording

Something that describes the actual model, e.g.: *"App installed. Its schema, tables and entity metadata ship in its migrations, and its entity classes in its npm packages — the host's CodeGen deliberately skips this schema. Restart MJAPI and rebuild MJExplorer to activate."*

## How this was found

While building a CI gate in `bizapps-forms` that enforces the self-contained-migration rule this message contradicts — see MemberJunction/bizapps-forms#160 and MemberJunction/bizapps-forms#162. That issue's investigation flagged the discrepancy and asked for it to be resolved before building guidance on top of the message; the code is unambiguous, so it was resolved in favour of `excludeSchemas`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01U89bU5U7JkdicWyAAyqHZz

Contributor guide

Open the contributing guide

Research direction

Read packages/OpenApp/Engine/src/install/install-orchestrator.ts at lines 500 and 1980-1983, along with plans/open-app-spec.md:387-396. Update the schema-install summary so it no longer directs operators to run host CodeGen, and ensure it describes restart MJAPI and rebuilding MJExplorer as the remaining activation steps.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
90/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.