Release Notes > 5.39.0
Date/Time and Identity (On/By) Meta Fields
Learn about the new date/time and identity-related meta fields, and how to handle the breaking changes.
Introduction
As mentioned in the changelog, with this release, we’ve revamped the date/time and identity-related meta fields. In order to do this, we had to introduce a couple of Headless CMS-related breaking changes.
Will these breaking changes affect you? It depends on if you’ve been adding custom code in your project, in which you are also relying on the existing content entry meta fields, like ownedBy
, publishedOn
, or createdOn
. For example, you may have have been using these in your:
- custom Headless CMS-related GraphQL API queries or mutations
- custom Headless CMS-related JavaScript (TypeScript) code (for example, lifecycle events)
If you don’t have any of the above, you can safely skip this article. Otherwise, please read on.
Breaking Changes and How to Handle Them
In the following sections, we outline all of the breaking changes you need to be aware of, and how to properly handle them.
1. RemovedownedBy
Field
Prior to this release, every content entry had an ownedBy
field, which was a reference to the user who initially created the entry. Its value would not change even if the entry was later updated by another user, nor it would change if a new revision was created.
With this release, we’ve removed this field because it’s no longer necessary. Instead, you use the createdBy
field.
Note that, previously, the createdBy
field was representing a revision-level value, but now it’s an entry-level value. If you really need to access the revision-level value, you can do so by using the new revisionCreatedBy
field.
2. RemovedpublishedOn
Field
Prior to this release, every content entry had a publishedOn
field, which held the date/time when the entry revision was published.
With this release, we’ve removed this field because it’s no longer necessary. Instead, you use the new set of fields:
firstPublishedOn
- holds the date/time when the entry was first publishedfirstPublishedBy
- holds the identity of the user who first published the entrylastPublishedOn
- holds the date/time when the entry was last publishedlastPublishedBy
- holds the identity of the user who last published the entry
Note that if you need to access the revision-level value, you can do so by using the new revision-level fields:
revisionFirstPublishedOn
- holds the date/time when the entry revision was first publishedrevisionFirstPublishedBy
- holds the identity of the user who first published the entry revisionrevisionLastPublishedOn
- holds the date/time when the entry revision was last publishedrevisionLastPublishedBy
- holds the identity of the user who last published the entry revision
3. Existing Meta Field Values Are Now Entry-Level, Not Revision-Level
Apart from the removal of above-mentioned fields, we’ve also changed the behaviour of the existing meta fields. Prior to this release, all of the meta fields contained revision-level values. With this release, they contain entry-level values.
createdOn
- now represents when an entry was createdsavedOn
- now represents when an entry was last savedcreatedBy
- now represents by whom an entry was createdmodifiedBy
- now represents by whom an entry was last modified
Note that, if you perhaps need to access the revision-level value, you can use the new revisionCreatedOn
, revisionSavedOn
, revisionCreatedBy
, and revisionModifiedBy
fields, respectively.
4. Removed Options on Publish Entry Mutation
With the 5.38.1 release, we’ve introduced the ability to skip updating the savedOn
and now removed publishedOn
fields upon publishing a content entry. This was done by introducing the options
GraphQL input on the existing publish{MODEL_ID}
mutation:
Essentially, this was introduced as an advanced feature, for users who were migrating to Webiny from another system and who needed to import their data, with the original savedOn
and publishedOn
values preserved. However, with this release, we’ve decided to remove these options, because they’re no longer necessary.
Previously, migrating an entry from a another system to Webiny would consist of two steps:
- Create a new entry via the
create{MODEL_NAME}
GraphQL mutation, and, among other fields, set thesavedOn
andpublishedOn
values to the original values from the other system. - Publish the entry with the
updatePublishedOn
andupdateSavedOn
options set tofalse
, so that the originalsavedOn
andpublishedOn
values are preserved (without these options, thesavedOn
andpublishedOn
values would be updated to the current date/time).
With this release, you can now simply do the following:
- Create a new entry via the
create{MODEL_NAME}
GraphQL mutation, with thesavedOn
andpublishedOn
values set to the original values from the other system, but also with thestatus
of the entry immediately set topublished
.
This way, you can create and publish entries in a single step, and preserve the original savedOn
and publishedOn
values.
So, to summarize, with this release, you can no longer skip updating the savedOn
and publishedOn
fields upon publishing an entry. Instead, you can simply create and publish an entry in a single step, and preserve the original savedOn
and publishedOn
values.
Data Migration
This release includes a data migration that will automatically migrate all existing content entries to use the new meta fields. Because of this, note that the duration of the migration varies, depending on the number of content entries stored in your database. For larger projects, for example with hundreds of thousands of content entries, the migration can take up to 15-30 minutes to complete.
The migration is run automatically after the API project application is deployed.
Assignments
The migration will perform the following revision-level and entry-level field value assignments on each content entry.
The code for what is described below can be found in our GitHub repository.
Revision-Level Fields
The revision-level fields are:
revisionCreatedOn
revisionModifiedOn
revisionSavedOn
revisionCreatedBy
revisionModifiedBy
revisionSavedBy
revisionFirstPublishedOn
revisionFirstPublishedBy
revisionLastPublishedOn
revisionLastPublishedBy
The migration will perform the following assignments on each content entry:
- The existing
createdOn
,savedOn
,createdBy
, andmodifiedBy
field values will be copied to the newrevisionCreatedOn
,revisionSavedOn
,revisionCreatedBy
, andrevisionModifiedBy
fields, respectively. - The newly introduced
revisionSavedBy
field will be populated with the value of the existingmodifiedBy
field. If it doesn’t exist,createdBy
field value will be used instead. - If the
modifiedBy
field value exists, the newly introducedrevisionModifiedOn
field will be populated with the value of the existingsavedOn
field. - The
publishedOn
field value will be used to set the value of the newly introducedrevisionFirstPublishedOn
andrevisionLastPublishedOn
fields. - Existing
modifiedBy
field value (orcreatedBy
ifmodifiedBy
doesn’t exist) will be used to set the value of the newly introducedrevisionFirstPublishedBy
andrevisionLastPublishedBy
fields.
Entry-Level Fields
The entry-level fields are:
createdOn
modifiedOn
savedOn
createdBy
modifiedBy
savedBy
firstPublishedOn
firstPublishedBy
lastPublishedOn
lastPublishedBy
The migration will perform the following assignments on each content entry:
createdOn
field will be populated with the value of the existingcreatedOn
field from the oldest revision of a given entry.createdBy
field will be populated with the value of the existingownedBy
field.- The
modifiedOn
,savedOn
,modifiedBy
, andsavedBy
entry-level fields will be populated with the values of the latest revision of a given entry. - The four publishing-related field values will be taken from the latest published revision of a given entry. These fields are:
firstPublishedOn
,firstPublishedBy
,lastPublishedOn
, andlastPublishedBy
.