Skip to content

ADR-0001/3: drop schema-level unique:true on User.email (lock-step with migration 002) #26

Description

@TheBoomerDev

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

  • backend/src/models/User.ts: email field retains lowercase: true, trim: true but loses unique: true.
  • On a fresh MongoDB with autoIndex=true (production-like), no IndexOptionsConflict or IndexAlreadyExists error in migration 002.
  • npm run typecheck rc=0; npm run lint rc=0; npm run test -- tests/migrations green.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    cleanupPre-existing lint/type cleanup; isolated PR

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions