Skip to content

[12.x] do assignment instead of mutating to handle immutable carbon object.#58498

Merged
taylorotwell merged 1 commit intolaravel:12.xfrom
MrPunyapal:fix/migration-issue
Jan 25, 2026
Merged

[12.x] do assignment instead of mutating to handle immutable carbon object.#58498
taylorotwell merged 1 commit intolaravel:12.xfrom
MrPunyapal:fix/migration-issue

Conversation

@MrPunyapal
Copy link
Contributor

I checked this laravel/cashier-stripe#1810 and some PRs related to it, and, like you, it was also working for me. But I was curious, so I did some deep digging into it, and I found that publishedAt property gets initialised with now(), which uses Date::now() behind the scenes and when someone uses Date::use(CarbonImmutable::class) at that moment it does not mutate. It creates a new object for each iteration. It creates all migrations with the same date and time that makes it resort in alphabetical order and that's why adding column migration runs before creating table migration.

@JaiveerChavda
Copy link

JaiveerChavda commented Jan 25, 2026

for more clarity here's the screenshot of migration created with same timestamp.

cashier-stripe-migration-issue

i created new laravel project with livewire starter kit.
and that by default comes with Date::use(CarbonImmutable::class); in AppServiceProvider class.
merging this PR will solve this issue.

@taylorotwell taylorotwell merged commit 47d0002 into laravel:12.x Jan 25, 2026
72 checks passed
@MrPunyapal MrPunyapal deleted the fix/migration-issue branch January 25, 2026 15:40
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.

3 participants