【发布时间】:2016-12-06 18:48:21
【问题描述】:
我在 Postgres 和 SQLite 中进行了迁移,并且遇到了 SQLite 数据库的问题。相同的迁移适用于 2 个不同的数据库。 Postgres 迁移是可以的,但不是 SQlite。我添加了用于更改表和添加新字段的迁移。
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
当我尝试添加 nullable() 字段时未创建,当我添加默认值 0 或 1 时出现约束错误,因为在相关表中我有第 1 行和第 2 行。如何解决?
【问题讨论】:
-
SQLite 中列的默认值为 null。所以我会更担心
nullable()不起作用。 -
浪费了一堆时间至今没有解决办法
-
声明 nullable 时的错误是什么?
标签: php mysql sqlite laravel-5