Like what we’re doing? Star us on GitHub!

Bug Report payload 1.6.19-20

Ronok
6 days ago
3

Enabling versioning in old collection. Does not show data on dashboard. but the data exist in db. If new data is add it is shown in dashboard.

image.png
image.png
image.png
  • Arskeliss
    6 days ago

    I have the same issue, i had data in the collection and after enabling versions it dissappeared, but the data was still in my db. Also, took new data without problem.

  • Jarrod
    Payload Team
    6 days ago

    Yeah so this is to be expected when flipping the switch on versions.



    Let me do my best to explain the issue here, and then how to resolve it.



    With versions enabled, a new collection will be created for the main collection - in your case it would be

    _tests_versions

    . When a document is saved, updated, deleted the corresponding versions collection will have a copy of the document created there. 5 separate updates to the main document means 5 versions will be created.



    Now, the admin panel dashboard always fetches from the versions collection so it can display the most up-to-date document. In your case, your documents were created before the versions table existed so it did not save any there. The admin panel goes to query the versions table and returns only the ones that you have recently saved after enabling versions.



    To resolve this, you can run the script in the following release notes that will loop over documents in your main collection and ensure every doc has at least 1 version doc. This way when you go to the admin panel you will see them all there. You will only need to run this script once for this collection, since it will create the first version for each doc that does not already have a version saved.



    Jump to the "Versions may need to be migrated" section here:

    https://github.com/payloadcms/payload/releases/tag/v1.6.1
  • Ronok
    5 days ago

    Thanks it worked..

Open the post
Continue the discussion in Discord
Can't find what you're looking for?
Get help straight from the Payload team with an Enterprise License.Learn More