【发布时间】:2015-02-05 11:29:25
【问题描述】:
我正在尝试运行 PHPUnit 测试。我在:memory 中为测试环境设置了SQLite。在我的设置中,我调用了Artisan::call('migrate'),但随后出现以下错误:
一般错误:1 无法添加默认值为 NULL 的 NOT NULL 列 (SQL: alter table "admins" add column "title" text not null)
基本上,任何修改现有表的迁移文件都会返回错误。为什么?
这是抱怨的文件迁移:
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class AddTitleToAdminsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('admins', function(Blueprint $table)
{
$table->text('title');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('admins', function(Blueprint $table)
{
$table->dropColumn('title');
});
}
}
【问题讨论】:
-
这个错误看起来像是您的迁移出了问题,而不是您调用它的方式。您能否通过产生此错误的迁移更新问题?
-
@lukasgeiter,感谢您的回复。我更新了我的答案
标签: laravel migration phpunit laravel-testing