Summary
Drop the schema-level unique: true from User.ts field email so the Mongoose
schema doesn't conflict with the migration-owned single-field unique index from
issue B. After this, the migration is the single source of truth for email uniqueness.
Spec
The decision lives at https://github.com/cargoffer/education_backend/blob/feat/adr-0001-global-email-uniqueness/docs/adr/0001-global-email-uniqueness.md. The cleanup maps to § Implementation Plan → 3. Schema cleanup.
This addresses ADR §Consequences "Mongoose-level vs migration-level asymmetry".
Acceptance criteria
Out of scope
- Login() normalization (separate concern).
- Frontend integration tests.
Dependencies
- BLOCKED BY issue B (the migration must run first to confirm no schema/index clash).
- BLOCKS issue D (tests), issue E (docs).
References
Summary
Drop the schema-level
unique: truefromUser.tsfieldemailso the Mongooseschema doesn't conflict with the migration-owned single-field unique index from
issue B. After this, the migration is the single source of truth for email uniqueness.
Spec
The decision lives at https://github.com/cargoffer/education_backend/blob/feat/adr-0001-global-email-uniqueness/docs/adr/0001-global-email-uniqueness.md. The cleanup maps to § Implementation Plan → 3. Schema cleanup.
This addresses ADR §Consequences "Mongoose-level vs migration-level asymmetry".
Acceptance criteria
backend/src/models/User.ts: email field retainslowercase: true, trim: truebut losesunique: true.IndexOptionsConflictorIndexAlreadyExistserror in migration 002.npm run typecheckrc=0;npm run lintrc=0;npm run test -- tests/migrationsgreen.Out of scope
Dependencies
References
backend/src/models/User.tsline 34 (current unique:true)backend/tests/setup.tsline ~30 (autoIndex=false in tests; production differs)