Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Adding a field and updating in the same migration #55679

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

Open
Zwartpet opened this issue May 8, 2025 · 1 comment
Open

Adding a field and updating in the same migration #55679

Zwartpet opened this issue May 8, 2025 · 1 comment

Comments

@Zwartpet
Copy link

Zwartpet commented May 8, 2025

Laravel Version

12.13.0

PHP Version

8.3

Database Driver & Version

sqlite

Description

Since 12.12.0 we can't add a field and update the field in the same migration anymore. Running into this issue when running pest which runs the migrations on an sqlite database.

SQLSTATE[HY000]: General error: 1 no such column: has_non_mappable_coverage (Connection: sqlite, SQL: update "policies" set "has_non_mappable_coverage" = 0, "updated_at" = 2025-05-08 13:42:04 where "has_non_mappable_coverage" is null and "policies"."deleted_at" is null)

Does still work with 12.11.1

<?php

use App\Models\Policy;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up()
    {
        Schema::table('policies', function (Blueprint $table) {
            $table->boolean('has_non_mappable_coverage')->nullable()->default(0);
        });

        Policy::where('has_non_mappable_coverage', null)->update(['has_non_mappable_coverage' => false]);
    }

    public function down()
    {
        ....
    }
};

Steps To Reproduce

Updating a field in the same migration where it's created and running the migrations or pest.

Caused by making the resolver static in: #55607

@Zwartpet Zwartpet changed the title Adding a field and updatingin the same migration Adding a field and updating in the same migration May 8, 2025
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

No branches or pull requests

1 participant