Skip to content

Enabling drafts on an existing collection makes all documents disappear in the admin view #2063

Closed

Description

@johannesschaffer

The main reason I did this was because after upgrading to 1.6 a lot of previously deleted documents showed up in the admin view. They couldn't be viewed, just gave an error it wasn't found. As such, they also couldn't be deleted. I therefore deleted the versions folder in the database and though Payload would recreate it. The only way to get any documents back into the admin view now is to keep drafts disabled for the collection (which I don't want to do)

Activity

  1. added
    status: needs-triage
    on Feb 10, 2023
  2. jmikrut commented on Feb 10, 2023

    @jmikrut
    Member

    Hey there - did you run the migration script that we released in our changelog for 1.6.0? That should have deleted all old / unused versions. It should also make sure that all of your documents appear correctly.

    If you haven’t tried it, will you give it a shot?

    Here’s a link:
    https://github.com/payloadcms/payload/blob/master/CHANGELOG.md#-versions-may-need-to-be-migrated

  3. jmikrut commented on Feb 10, 2023

    @jmikrut
    Member

    I should also note that enabling drafts on a collection that already exists will also require running that migration script. We definitely need to update our documentation because I think that right now, it says that you can enable drafts without doing anything else, but that’s no longer accurate.

    So the title of this issue is actually intended, and expected, although we might be able to improve this in the future. Once we introduce some type of smart, automatic migrations for config changes.

  4. johannesschaffer commented on Feb 10, 2023

    @johannesschaffer
    Author

    I tried the script but couldn't get it to work. The error message was cannot convert undefined or null to object at function.keys but unfortunately without line number where it occurred, so it's hard to debug

  5. johannesschaffer commented on Feb 10, 2023

    @johannesschaffer
    Author

    You should also update the docs that deletedRetention or something like that (I'm on mobile right now) isn't supported anymore

  6. jmikrut commented on Feb 10, 2023

    @jmikrut
    Member

    So, without running the script, everything you said makes perfect sense to me. It’s definitely a requirement that that script is run to be able to migrate if you have a lot of existing versions. We should try and figure out why it’s not running for you, and to do so if you can share with me whatever the error message is, no matter how nondescript it is, I will try and figure out what’s happening. Definitely need to get that thing going. PS I am also on mobile and doing speech to text, and I am amazed that it’s coming through as coherently as it is. Friday night!

  7. johannesschaffer commented on Feb 10, 2023

    @johannesschaffer
    Author

    Ok, works now 🤣. I had to upgrade first, then run the script. I was pretty sure I tried it, but apparently not 🙈. You should probably remark it in some way as it currently sounds like you have to do this as a preperation before upgrading.
    The error message with version 1.5.9 just in case you're interested anyways is:

    TypeError: Cannot convert undefined or null to object
        at Function.keys (<anonymous>)
        at relationshipPopulationPromise (C:\Users\johan\Programming\SBRENT-Payload\node_modules\payload\src\fields\hooks\afterRead\relationshipPopulationPromise.ts:148:12)
        at promise (C:\Users\johan\Programming\SBRENT-Payload\node_modules\payload\src\fields\hooks\afterRead\promise.ts:170:60)
        at C:\Users\johan\Programming\SBRENT-Payload\node_modules\payload\src\fields\hooks\afterRead\traverseFields.ts:35:31
        at Array.forEach (<anonymous>)
        at traverseFields (C:\Users\johan\Programming\SBRENT-Payload\node_modules\payload\src\fields\hooks\afterRead\traverseFields.ts:34:10)
        at promise (C:\Users\johan\Programming\SBRENT-Payload\node_modules\payload\src\fields\hooks\afterRead\promise.ts:260:21)
        at C:\Users\johan\Programming\SBRENT-Payload\node_modules\payload\src\fields\hooks\afterRead\traverseFields.ts:35:31
        at Array.forEach (<anonymous>)
        at traverseFields (C:\Users\johan\Programming\SBRENT-Payload\node_modules\payload\src\fields\hooks\afterRead\traverseFields.ts:34:10)
    
    
  8. github-actions commented on Sep 8, 2024

    @github-actions
    Contributor

    This issue has been automatically locked.
    Please open a new issue if this issue persists with any additional detail.

  9. locked as resolved and limited conversation to collaborators on Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions