Skip to content

Respect an explicit null modifier when changing a column - #254

Open
JonasPardon wants to merge 2 commits into
wintercms:wip/1.3from
JonasPardon:fix/change-explicit-null
Open

JonasPardon wants to merge 2 commits into
wintercms:wip/1.3from
JonasPardon:fix/change-explicit-null

Conversation

@JonasPardon

Copy link
Copy Markdown

On wip/1.3, changing a column with ->default(null) keeps the column's old default instead of removing it:

// earlier migration
$table->string('payment_method', 20)->default('niet betaald');

// later migration: Laravel 9 removed the default, wip/1.3 keeps 'niet betaald'
$table->string('payment_method', 20)->nullable()->default(null)->change();

The ->change() shims copy a modifier from the existing column when the migration didn't set it, and they check that with isset(). isset() is false for null, so an explicit ->default(null) (or ->comment(null), ...) is treated as "not set". This affects fresh installs and any new migration. It came up in wintercms/winter#1366, where a fresh database kept 'niet betaald' as the default.

  • Check array_key_exists() on the column's attributes instead, in MySqlBasedGrammar, PostgresGrammar, SqlServerGrammar and BlueprintState (SQLite). Laravel only adds the key when the modifier is called, so unset modifiers are still copied from the existing column.
  • Add a test per grammar. All four fail without the change. The SQLite one runs against a real in-memory database. I also checked it on a real MySQL 9.6 database: the default goes from 'niet betaald' to NULL.

🤖 Generated with Claude Code

The ->change() shims used isset() to decide whether the migration set a modifier, which is false for null, so ->default(null) kept the old default instead of removing it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3cb5a00a-4067-4ad1-afa4-42d6871bb201

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@JonasPardon

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mjauvin mjauvin added the maintenance PRs that fix bugs, are translation changes or make only minor changes label Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance PRs that fix bugs, are translation changes or make only minor changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants