Skip to content

Conversation

@busbyk
Copy link
Collaborator

@busbyk busbyk commented Oct 23, 2025

Description

The same or similar problem reported here: payloadcms/payload#14022

The underlying issue seems to be have been fixed in v3.60.0: payloadcms/payload#13813

This PR uses the fix suggested from payloadcms/payload#14022 which adds a valid lexical node definition as the default value for the field. We also include a default column.

Related Issues

Fixes #608

Key Changes

  • Adds full lexical node JSON structure for default value of content block column

Migration explanation

See src/migrations/20251024_203935_content_block_default_value_explanation.md for full explanation.

This PR includes a migration that uses the table recreation pattern that can result in data loss. I ran this locally and we don't experience data loss from this because these tables do not have any child foreign key relationships. So dropping these tables doesn't result in any cascade deletes.

This migration uses a column recreation pattern instead of the table recreation pattern.

I would love for reviewers to validate that logic before we merge this. Even though I did test this locally and it logically makes sense to me I want to make sure I'm not missing something.

@github-actions
Copy link

@busbyk busbyk marked this pull request as draft October 23, 2025 18:25
@github-actions
Copy link

github-actions bot commented Oct 24, 2025

Migration Safety Check

Found 20 potential issues:

20251024_203935_content_block_default_value.ts

Warning (line 11): ALTER keyword detected - review for data loss

`ALTER TABLE \`home_pages_blocks_content_columns\` ADD COLUMN \`__new_rich_text\` text DEFAULT '${DEFAULT_LEXICAL_VALUE}';`,

Warning (line 19): DROP keyword detected - review for data loss

await db.run(sql`ALTER TABLE \`home_pages_blocks_content_columns\` DROP COLUMN \`rich_text\`;`)

Warning (line 19): ALTER keyword detected - review for data loss

await db.run(sql`ALTER TABLE \`home_pages_blocks_content_columns\` DROP COLUMN \`rich_text\`;`)

Warning (line 21): ALTER keyword detected - review for data loss

sql`ALTER TABLE \`home_pages_blocks_content_columns\` RENAME COLUMN \`__new_rich_text\` TO \`rich_text\`;`,

Warning (line 21): RENAME keyword detected - review for data loss

sql`ALTER TABLE \`home_pages_blocks_content_columns\` RENAME COLUMN \`__new_rich_text\` TO \`rich_text\`;`,

Warning (line 27): ALTER keyword detected - review for data loss

`ALTER TABLE \`_home_pages_v_blocks_content_columns\` ADD COLUMN \`__new_rich_text\` text DEFAULT '${DEFAULT_LEXICAL_VALUE}';`,

Warning (line 35): DROP keyword detected - review for data loss

await db.run(sql`ALTER TABLE \`_home_pages_v_blocks_content_columns\` DROP COLUMN \`rich_text\`;`)

Warning (line 35): ALTER keyword detected - review for data loss

await db.run(sql`ALTER TABLE \`_home_pages_v_blocks_content_columns\` DROP COLUMN \`rich_text\`;`)

Warning (line 37): ALTER keyword detected - review for data loss

sql`ALTER TABLE \`_home_pages_v_blocks_content_columns\` RENAME COLUMN \`__new_rich_text\` TO \`rich_text\`;`,

Warning (line 37): RENAME keyword detected - review for data loss

sql`ALTER TABLE \`_home_pages_v_blocks_content_columns\` RENAME COLUMN \`__new_rich_text\` TO \`rich_text\`;`,

Warning (line 43): ALTER keyword detected - review for data loss

`ALTER TABLE \`pages_blocks_content_columns\` ADD COLUMN \`__new_rich_text\` text DEFAULT '${DEFAULT_LEXICAL_VALUE}';`,

Warning (line 51): DROP keyword detected - review for data loss

await db.run(sql`ALTER TABLE \`pages_blocks_content_columns\` DROP COLUMN \`rich_text\`;`)

Warning (line 51): ALTER keyword detected - review for data loss

await db.run(sql`ALTER TABLE \`pages_blocks_content_columns\` DROP COLUMN \`rich_text\`;`)

Warning (line 53): ALTER keyword detected - review for data loss

sql`ALTER TABLE \`pages_blocks_content_columns\` RENAME COLUMN \`__new_rich_text\` TO \`rich_text\`;`,

Warning (line 53): RENAME keyword detected - review for data loss

sql`ALTER TABLE \`pages_blocks_content_columns\` RENAME COLUMN \`__new_rich_text\` TO \`rich_text\`;`,

Warning (line 59): ALTER keyword detected - review for data loss

`ALTER TABLE \`_pages_v_blocks_content_columns\` ADD COLUMN \`__new_rich_text\` text DEFAULT '${DEFAULT_LEXICAL_VALUE}';`,

Warning (line 67): DROP keyword detected - review for data loss

await db.run(sql`ALTER TABLE \`_pages_v_blocks_content_columns\` DROP COLUMN \`rich_text\`;`)

Warning (line 67): ALTER keyword detected - review for data loss

await db.run(sql`ALTER TABLE \`_pages_v_blocks_content_columns\` DROP COLUMN \`rich_text\`;`)

Warning (line 69): ALTER keyword detected - review for data loss

sql`ALTER TABLE \`_pages_v_blocks_content_columns\` RENAME COLUMN \`__new_rich_text\` TO \`rich_text\`;`,

Warning (line 69): RENAME keyword detected - review for data loss

sql`ALTER TABLE \`_pages_v_blocks_content_columns\` RENAME COLUMN \`__new_rich_text\` TO \`rich_text\`;`,

Review these patterns and add backup/restore logic if needed. See docs/migration-safety.md for guidance.

@busbyk busbyk marked this pull request as ready for review October 24, 2025 20:54
@busbyk busbyk requested a review from stevekuznetsov October 24, 2025 20:54
@busbyk busbyk requested a review from rchlfryn October 24, 2025 20:54
@busbyk busbyk added this pull request to the merge queue Oct 27, 2025
Merged via the queue into main with commit 91fc56f Oct 27, 2025
7 checks passed
@busbyk busbyk deleted the bugfix/content-block-uncaught-error branch October 27, 2025 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistent Blank Screen of Death When Editing

4 participants