Skip to content

proof of concept: custom indexing in schemas#25767

Draft
innerdvations wants to merge 8 commits intodevelopfrom
feat/custom-indexes-in-schema
Draft

proof of concept: custom indexing in schemas#25767
innerdvations wants to merge 8 commits intodevelopfrom
feat/custom-indexes-in-schema

Conversation

@innerdvations
Copy link
Contributor

@innerdvations innerdvations commented Mar 18, 2026

What does it do?

Just playing around with some ideas for allowing custom indexes. This PR uses the existing and unsupported "indexes" property in a content type to add support for indexes targeting attributes (not database columns).

Basic indexes are simple and are supported via the examples in the included contributor documentation.

The biggest challenge (and still in progress / discussion) is allowing useful "unique" indexes -- with our current document model, that is impossible, and attempting to add a unique index to a content type table will break your Strapi.

So this PR demonstrates the automatic (non-breaking) creation of a new database structure, where we can define document-level attributes that are the same across all locales (but can differ by publication state) and locale-level attributes. It then becomes possible to enforce unique constraints at the database level.

In its current state, this PR is not ideal, but attempts to be minimally invasive, because it will only create the columns or tables necessary based on if it's necessary for a unique index (ie, for a unique global attribute we create a new table, and for a unique locale attribute we add a new column)

In reality, we should automatically create all columns and tables to support this universally, and allow defining an attribute as locale or global within itself, and then we wouldn't have to define a scope on the unique index; it would know just from what type of attribute it is. Defining it in the attribute itself would also allow us to give context to the front-end to let the users know on document-level values that changing it in one locale will change it in every locale.

Why is it needed?

Has been one of the top requested features for years:

https://feedback.strapi.io/developer-experience/p/custom-indexes-in-the-schema

How to test it?

Provide information about the environment and the path to verify the behaviour.

Related issue(s)/PR(s)

Let us know if this is related to any issue/pull request

@vercel
Copy link

vercel bot commented Mar 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
contributor-docs Ready Ready Preview, Comment Mar 18, 2026 0:02am

Request Review

@innerdvations innerdvations added the flag: don't merge This PR should not be merged at the moment label Mar 18, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 18, 2026

Size Change: 0 B

Total Size: 2.9 MB

ℹ️ View Unchanged
Filename Size
examples/getstarted/build/_baseEach-*********** 218 B
examples/getstarted/build/_baseMap-*********** 191 B
examples/getstarted/build/AdminSeatInfo-*********** 832 B
examples/getstarted/build/AIUsage-*********** 698 B
examples/getstarted/build/apiTokens-*********** 462 B
examples/getstarted/build/App-*********** 9.07 kB
examples/getstarted/build/ApplicationInfoPage-*********** 4.4 kB
examples/getstarted/build/ar.json-*********** 5.38 kB
examples/getstarted/build/AuthenticatedLayout-*********** 59.3 kB
examples/getstarted/build/AuthResponse-*********** 418 B
examples/getstarted/build/ca.json-*********** 3.76 kB
examples/getstarted/build/CardDragPreview-*********** 587 B
examples/getstarted/build/ColorPickerInput-*********** 4.24 kB
examples/getstarted/build/ComponentConfigurationPage-*********** 1.52 kB
examples/getstarted/build/ConfigureTheView-*********** 1.54 kB
examples/getstarted/build/constants-*********** 72 B
examples/getstarted/build/CreateActionEE-*********** 512 B
examples/getstarted/build/CreatePage-*********** 254 B
examples/getstarted/build/CreateView-*********** 362 B
examples/getstarted/build/cs.json-*********** 338 B
examples/getstarted/build/de.json-*********** 1.92 kB
examples/getstarted/build/dk.json-*********** 3.6 kB
examples/getstarted/build/dummy-preview-*********** 3.05 kB
examples/getstarted/build/EditConfigurationPage-*********** 1.08 kB
examples/getstarted/build/EditPage-*********** 4.74 kB
examples/getstarted/build/EditView-*********** 2.02 kB
examples/getstarted/build/EditViewPage-*********** 5.16 kB
examples/getstarted/build/en-*********** 74 B
examples/getstarted/build/en-GB-*********** 14.4 kB
examples/getstarted/build/en.json-*********** 381 B
examples/getstarted/build/es-*********** 74 B
examples/getstarted/build/es.json-*********** 1.07 kB
examples/getstarted/build/eu.json-*********** 10.4 kB
examples/getstarted/build/EventsTable-*********** 392 B
examples/getstarted/build/FieldTypeIcon-*********** 460 B
examples/getstarted/build/Form-*********** 5.43 kB
examples/getstarted/build/fr.json-*********** 794 B
examples/getstarted/build/getActionTypesDefaultMessages-*********** 497 B
examples/getstarted/build/getTrad-*********** 380 B
examples/getstarted/build/groupBy-*********** 371 B
examples/getstarted/build/gu.json-*********** 4.48 kB
examples/getstarted/build/he.json-*********** 1.63 kB
examples/getstarted/build/hi.json-*********** 11.1 kB
examples/getstarted/build/History-*********** 6.8 kB
examples/getstarted/build/HomePage-*********** 246 kB
examples/getstarted/build/hooks-*********** 92 B
examples/getstarted/build/hu.json-*********** 3.98 kB
examples/getstarted/build/id-*********** 7.51 kB
examples/getstarted/build/id.json-*********** 1.39 kB
examples/getstarted/build/index-*********** 1.68 kB
examples/getstarted/build/index.html 591 B
examples/getstarted/build/InstalledPlugins-*********** 778 B
examples/getstarted/build/isNil-*********** 121 B
examples/getstarted/build/it.json-*********** 15.3 kB
examples/getstarted/build/ja.json-*********** 1.41 kB
examples/getstarted/build/ko.json-*********** 5.2 kB
examples/getstarted/build/layout-*********** 3.17 kB
examples/getstarted/build/Layout-*********** 1.95 kB
examples/getstarted/build/ListConfigurationPage-*********** 4.23 kB
examples/getstarted/build/ListPage-*********** 1.97 kB
examples/getstarted/build/ListView-*********** 1.37 kB
examples/getstarted/build/ListViewPage-*********** 6.68 kB
examples/getstarted/build/Login-*********** 459 B
examples/getstarted/build/MagicLinkEE-*********** 384 B
examples/getstarted/build/ml.json-*********** 11.3 kB
examples/getstarted/build/ModalForm-*********** 243 B
examples/getstarted/build/ms.json-*********** 1.18 kB
examples/getstarted/build/nl.json-*********** 10.6 kB
examples/getstarted/build/no.json-*********** 5.47 kB
examples/getstarted/build/NoContentTypePage-*********** 453 B
examples/getstarted/build/NoPermissionsPage-*********** 230 B
examples/getstarted/build/Permissions-*********** 9.38 kB
examples/getstarted/build/pl.json-*********** 2.09 kB
examples/getstarted/build/PrivateRoute-*********** 248 B
examples/getstarted/build/ProfilePage-*********** 2.47 kB
examples/getstarted/build/pt-BR.json-*********** 1.12 kB
examples/getstarted/build/pt.json-*********** 1.51 kB
examples/getstarted/build/purchase-review-workflows-*********** 66.3 kB
examples/getstarted/build/PurchaseAuditLogs-*********** 70.5 kB
examples/getstarted/build/PurchaseContentHistory-*********** 80.9 kB
examples/getstarted/build/PurchaseContentReleases-*********** 55.9 kB
examples/getstarted/build/PurchaseSingleSignOn-*********** 25 kB
examples/getstarted/build/RelativeTime-*********** 393 B
examples/getstarted/build/ReleasesPage-*********** 4.1 kB
examples/getstarted/build/ReleasesSettingsPage-*********** 1.52 kB
examples/getstarted/build/router-*********** 399 B
examples/getstarted/build/ru-*********** 91 B
examples/getstarted/build/ru.json-*********** 241 B
examples/getstarted/build/sa.json-*********** 11.2 kB
examples/getstarted/build/schemas-*********** 3.16 kB
examples/getstarted/build/SearchInput-*********** 644 B
examples/getstarted/build/selectors-*********** 111 B
examples/getstarted/build/SelectRoles-*********** 1.02 kB
examples/getstarted/build/Settings-*********** 3.6 kB
examples/getstarted/build/SettingsPage-*********** 3.8 kB
examples/getstarted/build/SingleSignOnPage-*********** 1.8 kB
examples/getstarted/build/sk.json-*********** 748 B
examples/getstarted/build/sortable.esm-*********** 16.6 kB
examples/getstarted/build/sortBy-*********** 694 B
examples/getstarted/build/SSOProviders-*********** 754 B
examples/getstarted/build/strapi-*********** 1.88 MB
examples/getstarted/build/strapi-************ 844 B
examples/getstarted/build/sv.json-*********** 3.69 kB
examples/getstarted/build/Table-*********** 1.28 kB
examples/getstarted/build/tail-*********** 245 B
examples/getstarted/build/th.json-*********** 3.28 kB
examples/getstarted/build/TokenTypeSelect-*********** 122 kB
examples/getstarted/build/tr-*********** 83 B
examples/getstarted/build/tr.json-*********** 1.02 kB
examples/getstarted/build/transferTokens-*********** 501 B
examples/getstarted/build/uk-*********** 91 B
examples/getstarted/build/uk.json-*********** 3.32 kB
examples/getstarted/build/useAdminRoles-*********** 240 B
examples/getstarted/build/UseCasePage-*********** 1.36 kB
examples/getstarted/build/useDragLayer-*********** 179 B
examples/getstarted/build/useLicenseLimitNotification-*********** 710 B
examples/getstarted/build/useReviewWorkflows-*********** 1.33 kB
examples/getstarted/build/users-*********** 352 B
examples/getstarted/build/useWebhooks-*********** 642 B
examples/getstarted/build/validation-*********** 533 B
examples/getstarted/build/vi.json-*********** 1.41 kB
examples/getstarted/build/WidgetHelpers-*********** 520 B
examples/getstarted/build/Widgets-*********** 2.54 kB
examples/getstarted/build/zh-Hans.json-*********** 2.92 kB
examples/getstarted/build/zh.json-*********** 1.09 kB

compressed-size-action

@trunk-io
Copy link

trunk-io bot commented Mar 18, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flag: don't merge This PR should not be merged at the moment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant