Skip to content

feat: versioned migrations, schema fixes, admin bug fixes#457

Open
OlivierJM wants to merge 19 commits into
mainfrom
some-updates
Open

feat: versioned migrations, schema fixes, admin bug fixes#457
OlivierJM wants to merge 19 commits into
mainfrom
some-updates

Conversation

@OlivierJM

Copy link
Copy Markdown
Member

Summary

  • Plan 05 — Migration system: versioned MongoDB migration runner (migrate.ts), static registry, refactored 001-add-default-roles, migrations 002–005 (indexes, schema typo fixes, institution_id fields, institution collections), CLI script (npm run migrate)
  • Plan 03 — Schema fixes: settings typo, preferences type, courses key, user_roles permission_ids, feed_back _id required, page_links label, institution_memberships + institution_invites types/schemas/collections, institution_id + external_url added to T_RawMediaContentFields, pipeline preserveNullAndEmptyArrays fix
  • Plan 02 — Admin fixes: user update 500 fixed (there is an error 500 when attempting to update a user from the dashboard #427zfdz.object + safeParse), Institutions already wired in sidebar nav

Test Plan

  • All 124 existing tests pass (npm test)
  • TypeScript check clean (npm run type-check)
  • Run npm run migrate against a dev DB — confirm _migrations collection populated, all 5 migrations applied once, second run is a no-op
  • Verify user edit in admin dashboard no longer returns 500
  • Verify related media click still swaps without full reload

Notes

  • Migration 002 creates a unique index on users.email — verify no duplicate emails exist in prod before deploying (db.users.aggregate([{$group:{_id:"$email",n:{$sum:1}}},{$match:{n:{$gt:1}}}]))

🤖 Generated with Claude Code

OlivierJM and others added 14 commits April 19, 2026 17:16
…ated item click)

- Fix DB connection: replace per-call MongoClient with global singleton pattern
- Split MediaContentView into MediaViewer + MediaDetails (pure display components)
- Add MediaContentPlayer client component: owns active media state, intercepts
  related item clicks, fetches full metadata in background, syncs URL via
  router.replace without page navigation
- Add onSelect/activeMediaId props to RelatedMediaContentList for client-driven
  click interception with active item highlight
- Add fetchRelatedMediaClient for client-side related media re-fetch after swap
- Add docs/plans/05-database-migrations.md: versioned migration system plan
- Add docs/plans/01-04: resource view, admin panel, DB model, issues triage plans
- Create migrate.ts with runMigrations(db) runner that tracks applied migrations in _migrations collection with unique index
- Rename addDefaultRoles.ts → migrations/001-add-default-roles.ts, adapting to up(db: Db) signature with exported name constant
- Add migrations/index.ts as static registry
- Update init.ts to call runMigrations(db) instead of addDefaultRoles()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- 002: indexes for media_content, users, user-role-mappings, media_reactions
- 003: fix schema typos (settings.upated_at, courses.institutions_id)
- 004: institution_id indexes across 8 collections
- 005: institution_memberships and institution_invites collections with indexes (idempotent via NamespaceExists guard)
- src/scripts/migrate.ts: standalone CLI runner using MongoClient + runMigrations
- package.json: add "migrate" npm script via dotenv + tsx

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ntent

Add preserveNullAndEmptyArrays: true to the $unwind '$user' stage so
media content whose created_by_id doesn't match any user is no longer
silently dropped from random media results.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The schema used zfd.formData() but the body was read with request.json(),
causing a parse mismatch and a 500 error. Switched to a plain z.object()
schema to match the JSON request body correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix typo: settings.upated_at → updated_at (type + schema)
- Fix wrong type: preferences.updated_by_id Date → ObjectId (type + schema)
- Fix key mismatch: coursesSchema.institutions_id → institution_id
- Fix wrong embedded type: user_roles.permission_ids user_permissions[] → ObjectId[]
- Fix feed_back._id optional → required (type + schema)
- Fix page_links label copy-paste bug: 'Media Content' → 'Page Links'
- Add institution_memberships and institution_invites types, schemas, collections, and T_dbCollection entries
- Add institution_id?: string to T_RawMediaContentFields

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@dokploy-2025-09-04-9e6xob

dokploy-2025-09-04-9e6xob Bot commented Apr 19, 2026

Copy link
Copy Markdown

Dokploy Preview Deployment

Name Status Preview Updated (UTC)
next-app ❌ Failed Preview URL 2026-04-25T18:49:47.006Z

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.

1 participant