Repository navigation
Conversation
Creates or drops a plain single-column index on the field's column. The state is read back from the database (new `schema.is_indexed` on the column info of every dialect), so it is exposed in the fields API, GraphQL and schema snapshots. Primary key and unique columns are skipped, snapshots without the property do not produce a diff. Refs LaWebcapsule#402 Signed-off-by: Kyrylo Kuzmytskyi <slykirill@gmail.com>
slyk
added a commit
to slyk/d9
that referenced
this pull request
Oct 15, 2026
Signed-off-by: Kyrylo Kuzmytskyi <slykirill@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change description
Adds an Indexed checkbox next to Unique in the Schema tab of the advanced field creation mode (Data Model → field).
Discussed in #402. As suggested there, this is a first step: it covers plain single-column indexes only, and a full
index editor for a collection (with composite indexes) can be built on top of it later.
Behaviour
<table>_<column>_index). Unchecking it on an existing field drops that index, and checking it again adds it back.directus_fields. The schema inspector reports a newis_indexedboolean for every column: true when the column is the only column of a non-unique, non-primary index. Composite indexes
do not count, so they are never shown as checked and never dropped. Indexes created by hand in SQL show up too.
schema.is_indexedis also in the fields REST API, GraphQL andschema snapshot|diff|apply. A snapshot taken beforethis change has no
is_indexed; the diff ignores the property in that case, so old snapshots do not report everycolumn as changed.
columns (the unique constraint is already an index) and for foreign key columns that are already indexed (MySQL needs
that index for the constraint). A foreign key without an index (for example on Postgres) can still be indexed.
is_indexed: trueis ignored for primary key and unique columns. Turning Unique on drops the plain index.Changes
@wbce-d9/schema:Column.is_indexed, filled by every dialect (MySQL/MariaDB fromINFORMATION_SCHEMA.STATISTICS,Postgres and CockroachDB from
pg_index, SQLite fromPRAGMA index_list/index_info, MSSQL from the existing indexjoin, Oracle from
USER_IND_COLUMNS).FieldsService.addColumnToTablecreates/drops the index, same style asis_unique;is_indexedadded to thesnapshot whitelists in
sanitize-schema.tsand to the GraphQLschematype;get-snapshot-diff.tshandles oldsnapshots.
field-detail-advanced-schema.vue, twoen-USstrings (indexed,value_indexed).is_indexedin the fields reference.@wbce-d9/schema,@wbce-d9/api,@wbce-d9/appminor.Things a reviewer may want to weigh in on
Column.is_indexedis a new required property of a public type of@wbce-d9/schema. Code that buildsColumnobjects by hand has to add it (the test fixtures here needed
is_indexed: false).checked, but unchecking it fails with a database error (nothing is half-applied). Returning the real index name from
the inspector would fix that; I left it out to keep this PR small.
columnInfo()call.overview()is not changed.Testing note
api/src/services/fields.test.ts(index on create, none by default, no extra index next to a unique constraint, composite indexes not counted, add and drop on an existing column).server. Please check them, or I can adjust them if your CI or a test database shows a problem.
Locally on this branch: the four related API test files pass (19 tests),
tsc --noEmitpasses forapiandpackages/schema, and eslint and prettier pass on the changed files. I did not run the full app type check(
vue-tsc).Type of change
Related issues
Checklists
Development
Security
Only admins can change the data model, as before. The new inspector queries use bound parameters for the table name.
Network
No new endpoints;
is_indexedis added to the existing fieldschemaobject.Code review
necessary