无法添加NOT NULL列,默认值为NULL [duplicate]

I'm testing a laravel site using codeception and I've followed the following tute:

http://www.phplab.info/categories/laravel/how-to-specify-a-separate-database-for-unit-testing-on-laravel-5

I'm getting the following error:

[Illuminate\Database\QueryException] SQLSTATE[HY000]: General error: 1 Cannot add a NOT NULL column with default value NULL (SQL: alter table "markers" add column "user_id" integer not null)

Thanks in advance.

</div>

Your real problem is called ALTER TABLE. If you want to add NOT NULL column, you need to set DEFAULT for existing records! Otherwise, what can the database do?