@strapi/core 5.30.1 → 5.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/migrations/database/5.0.0-discard-drafts.d.ts +21 -7
- package/dist/migrations/database/5.0.0-discard-drafts.d.ts.map +1 -1
- package/dist/migrations/database/5.0.0-discard-drafts.js +1501 -58
- package/dist/migrations/database/5.0.0-discard-drafts.js.map +1 -1
- package/dist/migrations/database/5.0.0-discard-drafts.mjs +1502 -59
- package/dist/migrations/database/5.0.0-discard-drafts.mjs.map +1 -1
- package/dist/package.json.js +13 -13
- package/dist/package.json.mjs +13 -13
- package/dist/services/webhook-runner.js +2 -2
- package/dist/services/webhook-runner.js.map +1 -1
- package/dist/services/webhook-runner.mjs +2 -2
- package/dist/services/webhook-runner.mjs.map +1 -1
- package/dist/services/worker-queue.js +2 -2
- package/dist/services/worker-queue.js.map +1 -1
- package/dist/services/worker-queue.mjs +2 -2
- package/dist/services/worker-queue.mjs.map +1 -1
- package/package.json +13 -13
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Migration overview
|
|
3
|
+
* ===================
|
|
4
|
+
* 1. Create bare draft rows for every published entry, cloning only scalar fields (no relations/components yet).
|
|
5
|
+
* We do this with a single INSERT … SELECT per content type to avoid touching the document service for every single v4 entry.
|
|
3
6
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
7
|
+
* 2. Rewire all relations so the newly created drafts behave exactly like calling `documentService.discardDraft()`
|
|
8
|
+
* on every published entry:
|
|
9
|
+
* - Join-table relations (self, manyToMany, etc.) are copied in bulk.
|
|
10
|
+
* - Foreign keys (joinColumn relations) are updated so draft rows point to draft targets.
|
|
11
|
+
* - Component relations are copied while respecting the discard logic: each draft gets its own component instance,
|
|
12
|
+
* and the component’s relations (including nested components) are remapped to draft targets.
|
|
6
13
|
*
|
|
7
|
-
*
|
|
14
|
+
* 3. Components are duplicated at the database layer (new component rows + join-table rows). We deliberately clone
|
|
15
|
+
* instead of sharing component IDs so that draft edits don’t mutate published data.
|
|
8
16
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
17
|
+
* Why we do it this way
|
|
18
|
+
* ----------------------
|
|
19
|
+
* • Efficiency: calling the document service per entry would issue several queries per relation/component. The SQL
|
|
20
|
+
* batches mirror the service’s behavior but execute in O(content types × batches), so the migration scales to
|
|
21
|
+
* millions of entries.
|
|
22
|
+
|
|
23
|
+
* • Memory safety: any caches that track per-record information (component parent lookups, clone maps) are scoped to
|
|
24
|
+
* a single batch of 1,000 entries. Schema-level caches (component metadata, join table names) remain global because
|
|
25
|
+
* they’re tiny and reused.
|
|
12
26
|
*/
|
|
13
27
|
import type { Database, Migration } from '@strapi/database';
|
|
14
28
|
type DocumentVersion = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"5.0.0-discard-drafts.d.ts","sourceRoot":"","sources":["../../../src/migrations/database/5.0.0-discard-drafts.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"5.0.0-discard-drafts.d.ts","sourceRoot":"","sources":["../../../src/migrations/database/5.0.0-discard-drafts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAW5D,KAAK,eAAe,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAC9D,KAAK,IAAI,GAAG,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AA8pE3C;;;;;GAKG;AACH,wBAAuB,iBAAiB,CAAC,EACvC,EAAE,EACF,GAAG,EACH,GAAG,EACH,gBAAuB,GACxB,EAAE;IACD,EAAE,EAAE,QAAQ,CAAC;IACb,GAAG,EAAE,IAAI,CAAC;IACV,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,oDAgCA;AAED,eAAO,MAAM,qBAAqB,EAAE,SAQnC,CAAC"}
|