Skip to content

feat(schema): add native support for advanced index features#7160

Open
B4nan wants to merge 1 commit intomasterfrom
more-index-features
Open

feat(schema): add native support for advanced index features#7160
B4nan wants to merge 1 commit intomasterfrom
more-index-features

Conversation

@B4nan
Copy link
Member

@B4nan B4nan commented Feb 4, 2026

This PR adds comprehensive support for advanced index features across all SQL database drivers, enabling fine-grained control over index creation.

New Features

  • Column sort order (ASC/DESC) - MySQL, MariaDB, PostgreSQL, MSSQL, SQLite
  • NULLS FIRST/LAST ordering - PostgreSQL
  • Column prefix length - MySQL, MariaDB
  • Column collation - PostgreSQL, SQLite, MySQL, MariaDB
  • Covering indexes (INCLUDE columns) - PostgreSQL, MSSQL
  • Fill factor - PostgreSQL, MSSQL
  • Invisible/hidden indexes - MySQL 8+, MariaDB 10.6+, MongoDB
  • Disabled indexes - MSSQL
  • Clustered indexes - MariaDB, MSSQL
  • Fulltext/spatial index detection - MySQL, MariaDB (entity generator now outputs type: 'fulltext' / type: 'spatial')

Usage Example

@Entity()
@Index({
  properties: ['createdAt', 'name'],
  columns: [
    { name: 'createdAt', sort: 'DESC', nulls: 'LAST' },
    { name: 'name', sort: 'ASC' },
  ],
  include: ['email'],  // covering index
  fillFactor: 70,
})
export class Article {
  // ...
}

Database Support Matrix

Feature MySQL MariaDB PostgreSQL MSSQL SQLite MongoDB
Sort order (ASC/DESC) -
NULLS FIRST/LAST - - - - -
Column prefix length - - - -
Collation - -
INCLUDE columns - - - -
Fill factor - - - -
Invisible indexes - - -
Disabled indexes - - - - -
Clustered indexes - - - -
Deferrable constraints - - - - -

Closes #5967

@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

❌ Patch coverage is 76.62338% with 54 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.38%. Comparing base (9ed4010) to head (aaebd3f).

Files with missing lines Patch % Lines
packages/entity-generator/src/SourceFile.ts 42.10% 22 Missing ⚠️
packages/sql/src/schema/SchemaComparator.ts 46.15% 21 Missing ⚠️
packages/sql/src/schema/SchemaHelper.ts 61.11% 7 Missing ⚠️
packages/mariadb/src/MariaDbSchemaHelper.ts 92.30% 1 Missing ⚠️
packages/mssql/src/MsSqlSchemaHelper.ts 97.29% 1 Missing ⚠️
...ckages/sql/src/dialects/mysql/MySqlSchemaHelper.ts 97.14% 1 Missing ⚠️
packages/sql/src/schema/DatabaseTable.ts 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7160      +/-   ##
==========================================
- Coverage   99.68%   99.38%   -0.31%     
==========================================
  Files         250      250              
  Lines       21172    21385     +213     
  Branches     5033     5111      +78     
==========================================
+ Hits        21106    21254     +148     
- Misses         66      131      +65     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@B4nan B4nan force-pushed the more-index-features branch 2 times, most recently from 8e6313d to bf7e71e Compare February 4, 2026 21:56
@B4nan B4nan requested a review from boenrobot February 4, 2026 23:17
@B4nan B4nan force-pushed the more-index-features branch from bf7e71e to caea8e3 Compare February 5, 2026 09:48
@B4nan B4nan force-pushed the more-index-features branch from caea8e3 to aaebd3f Compare February 5, 2026 09:59
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.

Missing index features

1 participant