Resolve duplicate `AuditLog` entity — `src/common/database/entities/` and `src/infrastructure/audit/entities/` both define one
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- nodejs, typescript
Research direction
Start by checking which of the two audit-log.entity.ts files (src/common/database/entities/ and src/infrastructure/audit/entities/) is registered in the TypeORM forFeature calls and glob config in src/config/typeorm.config.ts, then diff their fields. Keep the one the running app uses, merge in any extra columns, and re-point imports; test/audit/provenance.e2e-spec.ts and the migrations under src/migrations/ must still pass. Done when only one AuditLog entity remains and the tests and migrations pass against a scratch database.
Written by the indexing model from the issue text.
Description
Problem
There are two files named audit-log.entity.ts, defining what is almost certainly the same entity:
src/common/database/entities/audit-log.entity.tssrc/infrastructure/audit/entities/audit-log.entity.ts
This is a persistence-level hazard, not just tidiness. Both are TypeORM entities, so if both are registered in the same TypeOrmModule.forFeature() call or discovered by glob configuration, TypeORM will attempt to create or map the same table twice — which surfaces as a confusing duplicate-metadata error, or as two classes writing to one table with different field mappings.
The same duplicate-name pattern exists elsewhere (confirmed by scanning src/ for repeated filenames):
| File | Locations |
|---|---|
audit-log.entity.ts |
src/common/database/entities/, src/infrastructure/audit/entities/ |
email.service.ts |
src/core/auth/, src/email/ |
kyc.guard.ts |
src/common/guard/, src/core/auth/ |
roles.decorator.ts |
src/common/decorators/, src/common/guard/ |
portfolio.module.ts |
src/portfolio/, src/investment/portfolio/ |
Why it matters
An audit log is the record the README calls out as central to "Observable & auditable" (line 32). Two definitions of it mean it is not clear which one is authoritative, which table is authoritative, or what the actual column set is. Anyone writing an audit query has to first work out which entity to import, and there is a real chance a migration written against one does not match the other.
Suggested Direction
- Determine which is registered. Check every
TypeOrmModule.forFeature([...])call and any glob-based entity discovery insrc/config/typeorm.config.ts. Whichever entity the running app actually uses is the one to keep. - Diff them field by field before choosing. If they have diverged, that is itself important — it may mean one is stale, or that columns exist in the database with no matching property. Compare against the real schema via
npm run migration:generatein a scratch database. - Keep one, delete the other, and re-point imports. Use
npx tsc --noEmitto find every reference. - Add a CI guard so this cannot recur. A short script in
scripts/that fails on duplicate entity filenames is cheap:
This is more targeted than the existingGet-ChildItem src -Recurse -Filter '*.entity.ts' | Group-Object Name | Where-Object Count -gt 1test:kyc-guard-scan, which covers guards only. - Apply the same treatment to the other duplicates in the table, in separate PRs.
Constraints
- Do not lose audit data. If the two entities have different columns, reconcile the wider schema and backfill rather than dropping fields.
- Existing migration files under
src/migrations/must keep applying cleanly. Verify against a scratch database, not production. - There are audit-related tests:
test/audit/provenance.e2e-spec.tsandsrc/infrastructure/audit/services. They must pass unchanged. src/common/database/entities/versussrc/infrastructure/audit/entities/also raises the module-ownership question — see thesrc/common/consolidation issue.
Acceptance Criteria
- Exactly one
AuditLogentity exists. - The surviving entity is the one the running app already uses.
- Field-level differences are documented; the union of columns is preserved.
- Migrations still apply cleanly against a scratch database.
- A CI check fails on duplicate
*.entity.tsfilenames. -
test/audit/provenance.e2e-spec.tsandnpm testpass.
- Dominant language
- TypeScript
- Stars
- 7
- Forks
- 55
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 5
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SourceXXL/alian_structure-api
-
good first issue help wanted security
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SourceXXL/alian_structure-api#266 ·
-
Parallelize the cache-warming loop in `cache-warming.service.ts` — warmers run strictly sequentiallyPossibly taken @syntaxsuuvam-spec claimed this 6 days ago. Opengood first issue performance
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SourceXXL/alian_structure-api#240 ·
-
documentation help wanted intermediate refactor
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
SourceXXL/alian_structure-api#215 ·
-
good first issue refactor tooling
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
SourceXXL/alian_structure-api#199 ·
-
help wanted intermediate refactor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
SourceXXL/alian_structure-api#196 ·
All issues in SourceXXL/alian_structure-api
Similar issues
-
bug engine
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
frostney/GocciaScript#1746 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
agilepathway/label-checker#739 · 4 comments ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
CopilotKit/OpenBot#800 ·
Maintainers usually reply within 1 day
-
Endpoint links in the tag operations list are below the 24px target sizePossibly taken @AdzerKI claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
ehmpathy/rhachet-roles-bhuild#471 ·
Maintainers usually reply within 1 day