Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

skrypt's avatar

SQLite migration failing to add deleted_at (soft delete column)

My php artisan migrate and :rollback work as expected. I'm using the following migration script on Laravel 4.

    Schema::table('orders', function(Blueprint $table) {
        $table->softDeletes();
        });
    }

When I run phpunit I get the following error on all of my tests:

Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such column: orders.deleted_at (SQL: select * from "orders" where "orders"."deleted_at" is null)

I'm using sqlite for my testing database in memory.

Any help would be greatly appreciated!

0 likes
3 replies
setnemo's avatar

I have the same issue. I checked my migration file and add $table->softDeletes();

Taelkir's avatar

This occurred for me after adding softDeletes to my Users table, so I was convinced this issue was related to Users.

After searching the whole project for the string "deleted_at" I eventually found an old bit of code where I was checking for that column in another table - in a query which happened to include a join to my Users table. So where it wasn't ambiguous before, it was now, thus causing this failure.

Please or to participate in this conversation.