我在Postgres和SQLite中进行了迁移,并且面临着SQLite数据库的问题。相同的迁移适用于2个不同的数据库。 Postgres迁移是好的,但不是SQlite。我添加了用于更改表格和添加新字段的迁移。使用SQLite进行Laravel迁移
public function up()
{
Schema::table('retailer_products_photo_fix', function ($table) {
$table->integer('currency_id')->unsigned();
$table
->foreign('currency_id')
->references('id')
->on('currency')
->onUpdate('cascade')
->onDelete('cascade')
;
$table->dropColumn('currency');
});
}
但被抛出以下错误:
General error: 1 Cannot add a NOT NULL column with default value NULL
当我尝试添加可空()字段没有创建,当我添加默认值0或1我是因为得到了相关约束错误表我有第1和第2行。这怎么解决?
SQLite中列的默认值为null。所以我会更关心'可空'()'不工作。 – Devon
废弃一堆时间到目前为止没有解决方案 –
声明为空时是什么错误? – Devon