Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocks in blocks not possible in v3 with Postgres #6957

Open
yobottehg opened this issue Jun 27, 2024 · 1 comment
Open

Blocks in blocks not possible in v3 with Postgres #6957

yobottehg opened this issue Jun 27, 2024 · 1 comment
Labels
status: needs-repro If an issue does not include a reproduction v3

Comments

@yobottehg
Copy link

yobottehg commented Jun 27, 2024

Link to reproduction

No response

Payload Version

3.0.0-Beta51

Node Version

20 LTS

Next.js Version

15.0-rc.0

Describe the Bug

When a Collection has a block field with some available blocks and one of these blocks has an additional blocks field It's not possible to generate a migration for this field.

We have a page collection with some Blocks. The blocks field looks like this:

{
      name: 'content',
      label: 'Content',
      type: 'blocks',
      minRows: 0,
      localized: true,
      blocks: [
        RichTextBlock,
        ImageBlock,
        TextImageBlock,
        LocalVideoBlock,
        RemoteVideoBlock,
        CTABlock,
        StructuredDataBlock,
        HighlightBoxBlock,
        AccordionBlock,
      ],
    },

The AccordionBlock now should allow for multiple accordion items where each one has a title and can have additional content elements inside.

The base fields for the accordionBlock look like this (First without the block in block feature):

fields: [
    {
      name: 'panels',
      label: 'Accordion Panels',
      type: 'array',
      fields: [{ name: 'title', label: 'Panel Title', type: 'text' }],
    },
  ],

This works. However when we add a blocks field inside the accordion fields we get different error messages:

1. version (It should work like this?)

fields: [
        { name: 'title', label: 'Panel Title', type: 'text' },
        {
          name: 'content',
          label: 'Content',
          type: 'blocks',
          localized: true,
          minRows: 0,
          blocks: [RichTextBlock, ImageBlock],
        },
      ],

yields [08:27:02] ERROR (payload): Error: cannot connect to Postgres. Details: Cannot read properties of undefined (reading 'Symbol(drizzle:Name)') when running payload migrate:create

Strange error which has nothing to do with the connection but seems like a serious issue in Drizzle?

2. version (differentiate blocks db table)

fields: [
        { name: 'title', label: 'Panel Title', type: 'text' },
        {
          name: 'content',
          label: 'Content',
          type: 'blocks',
          localized: true,
          dbName: 'accordion_item_content',
          minRows: 0,
          blocks: [RichTextBlock, ImageBlock],
        },
      ],

yields [08:28:22] ERROR (payload): There were 1 errors validating your Payload config [08:28:22] ERROR (payload): 1: Collection "pages" > Field "content" > "value" does not match any of the allowed type when running payload migrate:create.

If i remove the AccordionBlock from the pages collection it works again. So unsure which value is checked here.

If i remove the localized: true from the field i the yielded error is:

InvalidConfiguration: The table pages has multiple blocks with slug richText, but the schemas do not match. One is localized, but another is not. Block schemas of the same name must match exactly.

also with a different dbName for the accordion item.

I think it would work if I would create dedicated accordion_item_rich_text blocks but I would like to not go that route if possible.

Any hints on where to go from here would be very good!

Reproduction Steps

Please see bug description.

Adapters and Plugins

db-postgres

@yobottehg yobottehg added status: needs-triage Possible bug which hasn't been reproduced yet v3 labels Jun 27, 2024
@paulpopus
Copy link
Contributor

Hey @yobottehg, does this happen on the latest version of beta?

Also are you able to copy your configuration in a repro we can reproduce more easily please? Our test suite automatically tests for pg and we have a lot of nested blocks.

@paulpopus paulpopus added status: needs-repro If an issue does not include a reproduction and removed status: needs-triage Possible bug which hasn't been reproduced yet labels Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs-repro If an issue does not include a reproduction v3
Projects
None yet
Development

No branches or pull requests

2 participants