我如何定义默认值?
How i define a default value?
如何解决这个问题?
SQLSTATE[HY000]: General error: 1364 Field 'note' doesn't have a default value (SQL: insert into people
(name
, email
, user_id
, updated_at
, created_at
) values (Luis, luis@hotmail.com, 2, 2021-08-09 15:03:07, 2021-08-09 15:03:07))
我已经尝试过设置默认值,但我认为我没有做对
您应该决定使用默认 null
值或其他默认字符串。
对于默认空值:
Schema::table('people', function (Blueprint $table) {
$table->longText('note')->nullable()->after('email');
});
任何其他默认值应为:
Schema::table('people', function (Blueprint $table) {
$table->longText('note')->default('Some Default Value.')->after('email');
});
如何解决这个问题?
SQLSTATE[HY000]: General error: 1364 Field 'note' doesn't have a default value (SQL: insert into
people
(name
,user_id
,updated_at
,created_at
) values (Luis, luis@hotmail.com, 2, 2021-08-09 15:03:07, 2021-08-09 15:03:07))
我已经尝试过设置默认值,但我认为我没有做对
您应该决定使用默认 null
值或其他默认字符串。
对于默认空值:
Schema::table('people', function (Blueprint $table) {
$table->longText('note')->nullable()->after('email');
});
任何其他默认值应为:
Schema::table('people', function (Blueprint $table) {
$table->longText('note')->default('Some Default Value.')->after('email');
});