我想停止违反完整性约束:
1048 Column 'adresse' cannot be null
显示错误消息并将其变成警报或某些错误页面并返回主屏幕按钮或 smth
我是 laravel 和 phpmyadmin 的新手,但我对一条已经存在的消息有类似的问题。
最佳答案
那是因为 'addresse' 不可为空。您可以通过更改表或在现有迁移文件中编辑此行来更新它并刷新数据库(提示:如果您这样做,您将丢失所有数据)
要在不删除任何数据的情况下更改表并考虑表名称是 users
:
php artisan make:migration updateUsersAddresseFieldTable
Schema::table('users', function (Blueprint $table) {
$table->string('adresse')->nullable()->change();
});
php artisan 迁移
如果要适配已有的迁移文件并刷新:
$table->string('adresse')->nullable();
php artisan migrate:refresh
关于php - 将 "Integrity constraint violation: 1048 Column cannot be null "设为警告消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56720738/