156 Commits

Author SHA1 Message Date
Aurélien GEORGET e31fe3104a enhancement(core): lazy-load node-schedule and umzug at boot (#26267)
Two cron / migration providers eagerly require modules they only need
at runtime:

- `services/cron.ts` imports `node-schedule` (~90 ms via `Job` class)
  even when `server.cron` is empty. Defer the require to first
  `add()` / `start()`.
- `database/src/migrations/{internal,users}.ts` instantiate `Umzug`
  immediately in their factory, pulling in the inquirer and
  `@rushstack/ts-command-line` chain. Move the construction inside a
  lazy `provider()` closure so the require only fires on `shouldRun`,
  `up`, or `down`.

~100 ms saved on every boot of a project without active cron tasks
or pending migrations (the common case).
2026-05-29 16:38:56 +02:00
Weijie Sun 40413d376a fix: deleteMany respects filters combined with relation (#25420)
* Use query builder init in deleteMany

* test(api): deleteMany respects filters combined with relation

* fix(database): pick filter params in deleteMany init

Apply _q, where, and filters through init like count instead of where-only
or full findMany params, avoiding populate/pagination surprises. Expand API
and unit tests for relation filters, count parity, and ignored param keys.

* chore(database): clarify deleteMany relation cleanup TODO

Replace the vague bulk-query TODO with a concrete note that deleteMany
still skips per-row deleteRelations unlike single delete().

---------

Co-authored-by: Ben Irvin <ben.irvin@strapi.io>
Co-authored-by: Ben Irvin <ben@innerdvations.com>
2026-05-27 09:42:06 +00:00
bartsmartshore 1b37af9a70 enhancement(db): migration performance improvements (#25988)
* Run batches of document_id creation

* fix(core): use better caching in discard-draft

* fix(core): improve batch sizing & document_id loop efficiency // more caching improvements

* fix(core): componentHierarchyCaches moved back outside the loop

* test(migrations): add new tests and update existing

---------

Co-authored-by: Ben Irvin <ben.irvin@strapi.io>
Co-authored-by: Ben Irvin <ben@innerdvations.com>
2026-05-21 12:53:22 +00:00
Ben Irvin f9c6a232e3 fix(database): respect nested sort in populate for join-table relations (#26361)
* fix(database): respect nested sort in populate for join-table relations

* test(api): cover nested populate sort edge cases

Refs: #26359
2026-05-18 11:15:35 +00:00
Ben Irvin bdb24ffb0d fix(database): append primary key to ORDER BY for paginated selects (#26032) 2026-05-11 15:37:50 +02:00
Florent Baldino 2c48df2547 fix(db): deterministic schema hash by sorting tables before hashing (#26202) 2026-05-08 14:29:20 +00:00
Ben Irvin e907cd111b fix(database): morph typeField wins over same-name fields in populate (#26120)
* chore: remove early exit for morph relation types

* fix: issues with creating morphToOne relations

* chore: add tests

* test: add polymorphic relations tests

* fix(database): let morph typeField win over same-named target fields in populate

morphToOne and morphToMany: merge target row first, then set typeField (__type or custom)
so the polymorphic target UID is authoritative

* chore: fix ts

* docs: add contributor doc for polymorphic relations (#26121)

* test: apply morph to one

---------

Co-authored-by: Boaz Poolman <boaz_skater@hotmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-07 16:42:49 +02:00
Jamie Howard 4ec512cb11 fix: keep draft link on x-to-one relations non-dp to dp (#26179) 2026-05-06 09:23:21 +00:00
Ben Irvin 72535fb1c2 fix(database): run cleanOrderColumns updates sequentially (#26134)
Fix concurrent UPDATEs on the same join table that can deadlock Postgres
when renumbering order and inverse order columns.

Refs: https://github.com/strapi/strapi/issues/26131
2026-05-04 17:36:59 +02:00
Dominik Juriga 86fe764f4f feat: sort based on publish status (#25689)
* feat: sort based on publish status

* chore: remove redundant `any` type assertions

* fix: override sort if `status` filter is present

* fix(content-manager): status sort ignored hasPublishedVersion and publicationStatusFilter

* fix(utils): remove unused STATUS_ATTRIBUTE constant

* fix(content-manager): missing deps in useEffect for status sort cleanup

---------

Co-authored-by: Ziyi <daydreamnation@live.com>
2026-05-04 13:19:13 +02:00
Boaz Poolman ec72af97f0 Fix polymorphic relations in the document service API (#26099)
* chore: remove early exit for morph relation types

* fix: issues with creating morphToOne relations

* chore: add tests

* test: add polymorphic relations tests

---------

Co-authored-by: Ben Irvin <ben@innerdvations.com>
2026-04-30 11:58:02 +02:00
Ziyi 7f7c1c3403 fix(database): make 5.0.0-02-created-document-id migration idempotent (#26045)
Previously the migration could leave the DB in an unbootable state after
a statement_timeout or process kill: the document_id column existed but
the migration was not recorded, and the retry crashed with PG 42701
"column already exists". Additionally, when hasColumn returned true
the migration early-exited via continue, silently skipping the backfill
and leaving rows with NULL document_id.

- Swallow duplicate-column errors (PG 42701, MySQL 1060, generic
  /duplicate column/i) around ALTER TABLE ADD COLUMN to tolerate
  catalog drift / operator-applied partial fixes.
- Always run the document_id backfill when the column exists; the
  backfill already uses WHERE document_id IS NULL so it is a no-op on
  fully-populated tables and recovery on partially-populated ones.
- Add unit tests covering fresh run, column-already-exists,
  PG 42701, MySQL 1060, and non-duplicate errors.

Fixes CMS-689
2026-04-24 09:12:57 +02:00
Yohei Yamamoto 12dfbe97c9 chore: fix typos in comments and docs 2026-04-07 14:32:50 +02:00
guoyangzhen 8af200e5e0 fix: change return to continue in deleteRelations when using foreign keys (#25857)
* test(api): add morphToMany delete test

---------

Co-authored-by: Ben Irvin <ben.irvin@strapi.io>
2026-03-31 10:26:56 +02:00
Ben Irvin cc6b0c661b fix: use max batch sizes per dialect (#25390) 2026-03-30 09:39:46 +02:00
markkaylor ad0cb5e494 chore(core): parallelize and cache dynamic zone populate (#25685) 2026-03-12 14:43:58 +01:00
Jamie Howard 1153e05e6e [CM] request-scoped caching and parallelisation (#24999)
* fix(core): request-scoped model cache for validateParams

* chore(model-cache): enhance documentation

* feat: cache permission calculations in sanitize and validate services, reduce db queries

* chore: replace hardcoded prefix with constant for content manager store keys

* feat: parallel tranversal and further caching

* chore: extract shared utilities

* feat: add performance benchmarking for deeply nested content management

* chore: improve error handling in parallel processing of arrays

* chore: add TODO

* feat: enhance performance benchmark script

* Potential fix for code scanning alert no. 65: Clear-text logging of sensitive information

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* fix: improve error message

* chore(content-manager): revert dynamic populate depth

* feat: optimize permission checking and caching mechanisms

* test: componentService strapi mock

* fix: permission-checker tests types

* fix: remove redundant permission check in collection-types controller

* chore: remove performance benchmarking files and related configurations

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-01-22 15:49:27 +00:00
Araksya Gevorgyan e7ae51b01f feat(core): adding clear button to boolean toggle (#24836)
feat(core): adding clear button to boolean toggle
2025-12-02 17:33:05 +01:00
dollaransh17 222401a886 Fix spelling errors in error messages (#24501)
Changed 'occured' to 'occurred' in:
- DatabaseError constructor
- ApplicationError constructor
- API error handler

Authored-by: dollaransh17 <dollaransh17@users.noreply.github.com>
2025-10-09 15:00:00 +02:00
markkaylor 536eed0201 fix: database is corrupt with orphaned relations (#24316)
* fix: database is corrupt with orphaned relations

* chore: move script to document service and refactor

* fix: refactoring cleanup script

* fix: some improvements

* test(api): add unidirectional join table repair tests

* test(api): remove debug logs

* fix: orphaned relation nested compo (#24387)

---------

Co-authored-by: Bassel Kanso <basselkanso82@gmail.com>
Co-authored-by: Ben Irvin <ben@innerdvations.com>
Co-authored-by: Ben Irvin <ben.irvin@strapi.io>
2025-09-23 10:11:48 +02:00
Bassel Kanso a1da9b829e fix: syncing components in draft and publish relations (#24227)
Co-authored-by: Mark Kaylor <mark.kaylor@strapi.io>
Co-authored-by: Ben Irvin <ben.irvin@strapi.io>
Co-authored-by: Jamie Howard <48524071+jhoward1994@users.noreply.github.com>
2025-09-03 16:39:31 +02:00
Ziyi 56f4f610f1 fix(core): handle time to dateTime and dateTime to time conversion with postgres (#24073)
* fix(core): handle time to dateTime and dateTime to time conversion with default value

* fix(core): add conversion utility function, fix linting

* fix: add eorror handling for getCurrentColumnType

* use transaction connection

* fix: escape set default placeholder

* fix(database): linting issue
2025-08-05 13:12:47 +03:00
markkaylor 063e359981 fix: one to many relations returns published and draft versions (#23673) 2025-06-06 17:06:45 +02:00
DMehaffy b445ac2d35 enhancement(database): change schema hash from md5 to sha256 (#23116) 2025-05-21 13:32:43 +02:00
DMehaffy 76977370da fix: optimize schema validation lookup for mysql/mariadb (#23331) 2025-04-10 06:53:05 -07:00
Jean-Sébastien Herbaux f271284c75 fix(database): improve sub queries handling in the qb (#23129) 2025-03-20 10:31:36 +01:00
Bassel Kanso 4c7e9e6971 fix: make sure to clean _cmp tables from orphaned morph types (#23000) 2025-02-26 18:03:38 +02:00
Dhruv Maradiya 0521e81a13 fix: delete previous relations in morph to many relation (#22736) 2025-02-07 16:27:34 +01:00
Bassel Kanso a28002c793 fix: disable lifecycle hooks on transfers [v5] (#22651) 2025-01-21 14:44:24 +02:00
Ben Irvin 14fd433d38 fix(database): only drop indexes that exist; do not drop on create (#22633)
* fix(database): verify existance on drop but do not drop on create

* revert: keep mysql conditional
2025-01-14 16:44:14 +01:00
Ben Irvin 8f227a605a fix: name must be initialized 2024-12-17 14:51:17 +01:00
Ben Irvin d4d5d39c55 Merge branch 'fix/db-sync-fk' of https://github.com/strapi/strapi into fix/db-sync-fk 2024-12-16 17:19:38 +01:00
Ben Irvin d8be3e0366 Merge branch 'develop' into fix/db-sync-fk 2024-12-16 16:44:39 +01:00
Ben Irvin 575be3afd4 enhancement(database): add repair manager with component deletion fix (#22267) 2024-12-16 12:56:05 +01:00
Ben Irvin f47bf90b3f chore: add header comment 2024-12-16 10:30:00 +01:00
Ben Irvin cfda358b7f chore: refactor 2024-12-16 09:41:08 +01:00
Ben Irvin 6a649cd9b7 revert: reimplement fix for mysql fks 2024-12-16 09:40:09 +01:00
Ben Irvin 27465bf4d7 fix: check indexes before transaction 2024-12-13 18:33:47 +01:00
Ben Irvin e350eaa607 chore: fix comment 2024-12-13 14:20:58 +01:00
Ben Irvin 4378a7852d fix(database): delete indexes before creating if they already exist 2024-12-13 14:03:45 +01:00
Convly 7bc5339b03 fix: adjust polymorphic relation encoding and index mapping 2024-12-10 11:33:02 +01:00
Nikolay Shebanov faf42a9ea1 fix: resolve naming conflict in the v5 document_id migration (#22140) 2024-11-20 12:22:10 +01:00
Ben Irvin 403e03f1ae enhancement: add db info to startup logger (#21876) 2024-11-20 12:18:25 +01:00
Marvin Mottet 9e6d64696b fix: possible query ambiguity during Strapi v5 db migration (#21596)
In the migration 5.0.0-02-created-document-id, the GROUP BY in the SQL request does not precise the column's table which create an ambiguity when a content type use internationalization and one of its field is named "[name_of_the_type]Id".

Co-authored-by: Jamie Howard <48524071+jhoward1994@users.noreply.github.com>
2024-11-08 14:51:20 +00:00
Ben Irvin f3ad685d4b feat: reordering for polymorphic relations in Content API (#21928)
Co-authored-by: Marc Roig <Marc-Roig@users.noreply.github.com>
Co-authored-by: Marc <marc.roig.campos@strapi.io>
2024-11-08 09:07:22 +01:00
Ben Irvin 14882e7940 enhancement(db): allow connection to be a function (#21573)
Thanks to @evan-thinksync and @fardarter for their contributions
2024-10-24 17:05:47 +02:00
Marc Roig c823b10e98 fix: search by numeric numbers in a relation (#21873) 2024-10-16 13:19:38 +02:00
Marc Roig d6fc84a403 fix: loading relations without DP fails after migrating to v5 (#21501)
* fix: loading entries without DP

* fix: time format

* fix: unit test

* fix: set published at with db query
2024-10-09 11:22:11 +02:00
Ben Irvin 006a21d394 fix: ignore order when checking index diff (#21576) 2024-10-04 15:11:11 +02:00
Ben Irvin 9bc666db2f Merge branch 'develop' into feature/add-mariadb-migration-support 2024-09-25 17:34:31 +02:00