feat: versioned migrations, schema fixes, admin bug fixes#457
Open
OlivierJM wants to merge 19 commits into
Open
feat: versioned migrations, schema fixes, admin bug fixes#457OlivierJM wants to merge 19 commits into
OlivierJM wants to merge 19 commits into
Conversation
…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 Preview Deployment
|
…timeout, limit:1 for single-item fetch
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
migrate.ts), static registry, refactored001-add-default-roles, migrations 002–005 (indexes, schema typo fixes, institution_id fields, institution collections), CLI script (npm run migrate)settingstypo,preferencestype,courseskey,user_rolespermission_ids,feed_back_id required,page_linkslabel,institution_memberships+institution_invitestypes/schemas/collections,institution_id+external_urladded toT_RawMediaContentFields, pipelinepreserveNullAndEmptyArraysfixzfd→z.object+safeParse), Institutions already wired in sidebar navTest Plan
npm test)npm run type-check)npm run migrateagainst a dev DB — confirm_migrationscollection populated, all 5 migrations applied once, second run is a no-opNotes
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