Laravel-activitylog: Unknown column 'subject_id' in 'field list'

Created on 7 Nov 2016  路  1Comment  路  Source: spatie/laravel-activitylog

I'm just in the process of migrating from spatie/activitylog to this. Using v1.10.1 with L5.2 v5.2.45.

I've followed all the steps to setup automatic model logging, but, I'm getting the SQL error after a new model is created: Column not found: 1054 Unknown column 'subject_id' in 'field list'

Illuminate\Database\QueryException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'subject_id' in 'field list' (SQL: insert into `activity_log` (`subject_id`, `subject_type`, `causer_id`, `causer_type`, `properties`, `description`, `log_name`, `updated_at`, `created_at`) values (193, App\Model, 483, App\User, {"attributes":{"title":"Consequatur optio.","description":"Accusamus omnis quam deserunt neque.","subtitle":"Porro et officiat.","published":1}}, created, default, 2016-11-07 04:02:30, 2016-11-07 04:02:30))
vendor/laravel/framework/src/Illuminate/Database/Connection.php:729
vendor/laravel/framework/src/Illuminate/Database/Connection.php:685
vendor/laravel/framework/src/Illuminate/Database/Connection.php:458
vendor/laravel/framework/src/Illuminate/Database/Connection.php:414
vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php:32
vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2107
vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1423
vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1628
vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1597
vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1488
vendor/spatie/laravel-activitylog/src/ActivityLogger.php:146
vendor/spatie/laravel-activitylog/src/Traits/LogsActivity.php:35
vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:221
vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1686
vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1614
vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1488
vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:87
database/factories/ModelFactory.php:66
vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:135
vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:2314
vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:143
vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:106
vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:84
/tests/DownloadTest.php:18

Caused by
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'subject_id' in 'field list'

If anyone can point me in the direction of what may be causing this, that would be great.

Also, is it possible that a __construct(), boot(), or other attribute on the model could be interfering?

Most helpful comment

There error message it's giving you is pretty clear. The subject_id column doesn't exist in your DB. I'm not familiar with the previous version, but if it didn't use this field, you'll need to create a migration to add it. You can create a default migration (as described in the README) and then modify that to suit your needs.

>All comments

There error message it's giving you is pretty clear. The subject_id column doesn't exist in your DB. I'm not familiar with the previous version, but if it didn't use this field, you'll need to create a migration to add it. You can create a default migration (as described in the README) and then modify that to suit your needs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

farshadff picture farshadff  路  4Comments

lucianobosco picture lucianobosco  路  5Comments

damosse31 picture damosse31  路  5Comments

TheFrankman picture TheFrankman  路  5Comments

ianrussel picture ianrussel  路  5Comments