#Grouping fields in Payload, relationship change and data loss: bug or a feature? (Drizzle related?)

1 messages · Page 1 of 1 (latest)

final fog
#

So I'm using the latest version of Payload with Nextjs 15 and Postgres

I would like to be able to group or ungroup fields without losing/modifying data:

Payload and/or Drizzle seems to be saving a different state for uploading images via grouped fields, and uploading images via ungrouped fields

In other words, the images that I have uploaded are not the same when I switch to group or no group:

should I be using one of these commands to resolve this?
pnpx payload migrate:create name pnpm generate:importmap

or is this more to do how Postgres works? Or does it not really matter that much with Sql/NoSql when Drizzle involved?

Unfortunately I am not experienced with database architecture to understand what is happening here. Also not sure if it's best approach to always rename tables, or to press Y for data loss and create a new table. In this case it doesn't seem to matter, similar result

ungrouped:
fields: [ { name: 'featuredImage', type: 'upload', relationTo: 'media', required: false, admin: {}, }, { name: 'exteriorImages', type: 'upload', relationTo: 'media', hasMany: true, admin: {}, }, { name: 'interiorImages', type: 'upload', relationTo: 'media', hasMany: true, admin: {}, }, ...

grouped:
`fields: [
{
name: 'images',
label: 'Images',
type: 'group',
admin: {
position: 'sidebar',
},

  fields: [
    {
      name: 'featuredImage',
      type: 'upload',
      relationTo: 'media',
      required: false,
      admin: {},
    },
    {
      name: 'exteriorImages',
      type: 'upload',
      relationTo: 'media',
      hasMany: true,
      admin: {},
    },
    {
      name: 'interiorImages',
      type: 'upload',
      relationTo: 'media',
      hasMany: true,
      admin: {},
    },
  ],
}

...,`

dire oracle
#

Grouped fields is both a UI and a data organization concept, so essentially you are renaming fields

#

If you want only the UI grouping, I recommend Collapsible, or add UI heading fields for separation

#

I also don't recommend group fields in general because the list UI doesn't work well with it