Vla*_*tus 2 php mysql sqlite laravel-5
我在 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');
});
}
Run Code Online (Sandbox Code Playgroud)
但抛出了以下错误:
General error: 1 Cannot add a NOT NULL column with default value NULL
Run Code Online (Sandbox Code Playgroud)
当我尝试添加 nullable() 字段时,未创建字段,并且当我添加默认值 0 或 1 时,我收到约束错误,因为在相关表中我有第 1 行和第 2 行。如何解决这个问题?
| 归档时间: |
|
| 查看次数: |
4307 次 |
| 最近记录: |