@strapi/review-workflows 0.0.0-next.840550dc97a3782302ddf918d3a0d07e59dd11eb → 0.0.0-next.8f63e1055db761e0213cb6610f80c55658196ae1

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.
@@ -6562,8 +6562,40 @@ function extendReviewWorkflowContentTypes({ strapi: strapi2 }) {
6562
6562
  });
6563
6563
  }
6564
6564
  }
6565
+ function persistRWOnDowngrade({ strapi: strapi2 }) {
6566
+ const { removePersistedTablesWithSuffix, persistTables } = getAdminService("persist-tables");
6567
+ return async ({ contentTypes: contentTypes2 }) => {
6568
+ const getStageTableToPersist = (contentTypeUID) => {
6569
+ const { attributes, tableName } = strapi2.db.metadata.get(contentTypeUID);
6570
+ const joinTableName = attributes[ENTITY_STAGE_ATTRIBUTE].joinTable.name;
6571
+ return {
6572
+ name: joinTableName,
6573
+ dependsOn: [{ name: tableName }]
6574
+ };
6575
+ };
6576
+ const getAssigneeTableToPersist = (contentTypeUID) => {
6577
+ const { attributes, tableName } = strapi2.db.metadata.get(contentTypeUID);
6578
+ const joinTableName = attributes[ENTITY_ASSIGNEE_ATTRIBUTE].joinTable.name;
6579
+ return {
6580
+ name: joinTableName,
6581
+ dependsOn: [{ name: tableName }]
6582
+ };
6583
+ };
6584
+ const enabledRWContentTypes = fp.pipe([
6585
+ getVisibleContentTypesUID,
6586
+ fp.filter((uid) => hasStageAttribute(contentTypes2[uid]))
6587
+ ])(contentTypes2);
6588
+ const stageJoinTablesToPersist = enabledRWContentTypes.map(getStageTableToPersist);
6589
+ await removePersistedTablesWithSuffix("_strapi_stage_lnk");
6590
+ await persistTables(stageJoinTablesToPersist);
6591
+ const assigneeJoinTablesToPersist = enabledRWContentTypes.map(getAssigneeTableToPersist);
6592
+ await removePersistedTablesWithSuffix("_strapi_assignee_lnk");
6593
+ await persistTables(assigneeJoinTablesToPersist);
6594
+ };
6595
+ }
6565
6596
  const register = async ({ strapi: strapi2 }) => {
6566
6597
  strapi2.hook("strapi::content-types.beforeSync").register(migrateStageAttribute);
6598
+ strapi2.hook("strapi::content-types.afterSync").register(persistRWOnDowngrade({ strapi: strapi2 }));
6567
6599
  strapi2.hook("strapi::content-types.afterSync").register(migrateReviewWorkflowStagesColor).register(migrateReviewWorkflowStagesRoles).register(migrateReviewWorkflowName).register(migrateWorkflowsContentTypes).register(migrateDeletedCTInWorkflows);
6568
6600
  reviewWorkflowsMiddlewares.contentTypeMiddleware(strapi2);
6569
6601
  extendReviewWorkflowContentTypes({ strapi: strapi2 });
@@ -7332,7 +7364,9 @@ const stages$1 = ({ strapi: strapi2 }) => {
7332
7364
  const entity = await strapi2.documents(model).update({
7333
7365
  documentId,
7334
7366
  locale,
7335
- data: { [ENTITY_STAGE_ATTRIBUTE]: stage },
7367
+ // Stage doesn't have DP or i18n enabled, connecting it through the `id`
7368
+ // will be safer than relying on the `documentId` + `locale` + `status` transformation
7369
+ data: { [ENTITY_STAGE_ATTRIBUTE]: fp.pick(["id"], stage) },
7336
7370
  populate: [ENTITY_STAGE_ATTRIBUTE]
7337
7371
  });
7338
7372
  metrics.sendDidChangeEntryStage();