如何解决这个php laravel数据库问题
SQLSTATE[23000]:完整性约束冲突:1048列 “发布状态”不能为空(SQL:插入到如何解决这个php laravel数据库问题,php,database,laravel,Php,Database,Laravel,SQLSTATE[23000]:完整性约束冲突:1048列 “发布状态”不能为空(SQL:插入到categories (类别名称,类别说明,出版物状态, 在处更新,在处创建)价值观(saiful,好人,2020-01-20 20:07:522020-01-20 20:07:52) 您需要为发布状态设置一个值,或者修改数据库中的列以允许空值 要允许空值,可以通过运行以下命令创建迁移:php artisan make:migration allow_publication_status_nullab
categories
(类别名称
,类别说明
,出版物状态
,
在
处更新,在
处创建)价值观(saiful,好人,2020-01-20
20:07:522020-01-20 20:07:52)
您需要为发布状态设置一个值,或者修改数据库中的列以允许空值 要允许空值,可以通过运行以下命令创建迁移:
php artisan make:migration allow_publication_status_nullable_To_categories_table
然后打开新的迁移文件并添加:
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('categories', function (Blueprint $table) {
//I'm assuming that the column publication_status is a integer
//if not, just change it to the correct column type
$table->integer('publication_status')->nullable()->change();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('categories', function (Blueprint $table) {
$table->integer('publication_status')->nullable(false)->change();
});
}
最后运行
php artisan migrate
错误很明显。您没有为发布状态
提供值,您的数据库需要一个值。所以要解决这个问题。您有5个列名和5个值,但是列publication\u status
是notnull
列,所以您必须提供值