FN-5896: persist mission-goal linkage in schema
Persist mission↔goal relationships through the core mission schema and store APIs. - add the mission_goals join table, schema migration coverage, and schema version bump to 101 - add MissionStore goal link/unlink/list helpers plus a MissionGoalLink type and emitted linkage events - add regression tests for persistence, idempotency, ordering, and cascade behavior, and document the new linkage model with a published changeset Files changed: .changeset/fn-5896-mission-goal-linkage.md | 5 + docs/missions.md | 19 +++ docs/storage.md | 1 + packages/core/src/__tests__/db-migrate.test.ts | 49 ++++++- packages/core/src/__tests__/db.test.ts | 34 ++--- packages/core/src/__tests__/goals-schema.test.ts | 4 +- packages/core/src/__tests__/insight-store.test.ts | 10 +- .../src/__tests__/merge-request-record.test.ts | 2 +- .../core/src/__tests__/mission-goals-link.test.ts | 142 +++++++++++++++++++++ packages/core/src/__tests__/mission-store.test.ts | 4 +- packages/core/src/__tests__/run-audit.test.ts | 2 +- packages/core/src/__tests__/secrets-schema.test.ts | 6 +- .../core/src/__tests__/store-merge-queue.test.ts | 2 +- packages/core/src/__tests__/task-documents.test.ts | 2 +- packages/core/src/db.ts | 31 ++++- packages/core/src/mission-store.ts | 111 ++++++++++++++++ packages/core/src/mission-types.ts | 6 + .../src/store/__tests__/roadmap-store.test.ts | 2 +- 18 files changed, 391 insertions(+), 41 deletions(-) Fusion-Task-Id: FN-5896 Fusion-Task-Lineage: a4c7c495-b20a-454b-9605-782671cdd8c8
This commit is contained in:
@@ -23,6 +23,25 @@ Mission: Improve Reliability
|
||||
Task: FN-214
|
||||
```
|
||||
|
||||
## Mission ↔ Goal persistence
|
||||
|
||||
Missions and goals are stored independently, but Fusion now persists an optional many-to-many linkage in the `mission_goals` join table.
|
||||
|
||||
- Columns: `missionId`, `goalId`, `createdAt`
|
||||
- Primary key: `(missionId, goalId)`
|
||||
- Foreign keys: `missionId → missions.id`, `goalId → goals.id`
|
||||
- Delete behavior: both foreign keys use `ON DELETE CASCADE`, so removing either parent deletes only the corresponding join rows
|
||||
- Reverse lookups are indexed via `idxMissionGoalsGoalId`
|
||||
|
||||
`MissionStore` owns the linkage CRUD surface:
|
||||
|
||||
- `linkGoal(missionId, goalId)` — idempotently create a link and return `{ missionId, goalId, createdAt }`
|
||||
- `unlinkGoal(missionId, goalId)` — remove a link and report whether anything changed
|
||||
- `listGoalIdsForMission(missionId)` — list linked goals in deterministic creation order
|
||||
- `listMissionIdsForGoal(goalId)` — list linked missions in deterministic creation order
|
||||
|
||||
Existing missions are **not** backfilled with goal links as part of this schema change; that decision is deferred to FN-5898.
|
||||
|
||||
## Creating Missions
|
||||
|
||||
### Mission base branch defaults
|
||||
|
||||
Reference in New Issue
Block a user