我在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