what's the output of your migration in the console?
Also the table in the first example is products then in the second its videos, is this by design?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a migration that creates a table with the following collumn:
Schema::create('products', function (Blueprint $table) {
...
$table->boolean('active')->nullable();
...
});
Now i need this column value to be false by default. So i created another migration to update this column. I tried something like this:
if (Schema::hasColumn('products', 'active')) {
Schema::table('products', function (Blueprint $table) {
$table->boolean('active')->default(false)->change();
});
}
But it doesnt seems to work.
Is it possible to acomplish this?
Ok. I found the issue. I forgot to load a fresh instance of the product. Solved this by adding refresh():
$this->assertFalse($inactiveProducts->get(0)->refresh()->active);
Also set the active attribute to cast as boolean on the Product model: https://stackoverflow.com/a/58939221
protected $casts = [
'active' => 'boolean',
];
Now the test is passing ✅✅
Turns out the migration was right, i was only missing the refresh() on the test, which was causing the attribute to be null.
Thanks for the help!
Please or to participate in this conversation.