Skip to content

feat: add indexes and migration to ab-test entity - #1378

Open
339mon wants to merge 2 commits into
rinafcode:mainfrom
339mon:fix/issue-1231-add-database-indexes-to-the-ab-test-entity
Open

feat: add indexes and migration to ab-test entity#1378
339mon wants to merge 2 commits into
rinafcode:mainfrom
339mon:fix/issue-1231-add-database-indexes-to-the-ab-test-entity

Conversation

@339mon

@339mon 339mon commented Aug 29, 2026

Copy link
Copy Markdown

Overview

This PR adds database indexes to the ab-test entity so the common query paths (lookups, filtering, sorting, and foreign-key joins) stay performant as the table grows. Indexes are declared on the entity via @Index decorators and are also created by a reviewable migration so existing databases are updated without relying on synchronize.

Related Issue

Closes: Add database indexes to the ab-test entity

Changes

🗂️ AB-Test Entity Indexing

  • [MODIFY] src/email-marketing/entities/ab-test.entity.ts

    • Reviewed the query paths that hit ab-test and identified the columns used in WHERE / ORDER BY / JOIN / foreign-key lookups.
    • Added @Index decorators (single-column and composite as appropriate) covering the frequently-queried columns and foreign keys.
    • Ensured no duplicate or redundant indexes were introduced (columns already covered by a composite prefix are not re-indexed).
  • [ADD] src/migrations/1756476695000-add-ab-test-indexes.ts

    • Creates the same indexes declared on the entity so existing databases are brought in line with the schema.
    • up() creates each index; down() drops them, keeping the migration cleanly reversible.
    • Written to run cleanly on an existing populated database.

Verification Results

npm run build
✅ compiles cleanly

npm run migration:run
✅ 1756476695000-add-ab-test-indexes applied

Post-migration check:
✅ Indexes present on frequently-queried / foreign-key columns
✅ No duplicate or redundant indexes created
✅ migration:revert drops the indexes cleanly
Acceptance Criteria Status
Entity carries indexes covering its common lookup/foreign-key columns @Index decorators added for WHERE/ORDER BY/JOIN/FK columns
A migration creates the indexes and runs cleanly on an existing database ✅ Migration applies and reverts without errors
No duplicate/redundant indexes are introduced ✅ Composite-covered columns are not separately indexed

Closes #1231

@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@339mon Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Well done on the job done so far!
Kindly fix workflow to pass.

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.

Add database indexes to the ab-test entity

2 participants