Laravel table * 没有名为 * 的列
Laravel table * has no column named *
我的单元测试最近开始失败。我收到此错误:
PDOException: SQLSTATE[HY000]:
General error: 1 table loan_details has no column named start_month
发生的行,我有这个代码:
$loan = LoanDetails::create(['loan_percentage' => .8,
'loan_product_id' => 1,
'interest_rate' => .5,
'start_month' => 0,
'term' => 120,
'fixed_finance_fee' => 0,
'variable_finance_Fee' => 0,
'valid_from' => '2015-01-01'
]);
如果我注释掉 "start_month" 行,那么它在逻辑上是有效的。
在我的单元测试设置中,我 运行 所有迁移(大约 80)。
我有一个看起来像这样的迁移:
Schema::table('loan_details', function(Blueprint $table){
$table->integer('start_month')->unsigned()->after('interest_only')->default(0);
$table->decimal('balloon_percent',4,3)->after('term')->nullable();
$table->integer('balloon_month')->after('balloon_percent')->nullable();
$table->dropColumn('ordinal_rank');
});
所以,我想知道是否所有的迁移都没有 运行ning 所以我 运行 这个代码:
$rows = DB::table('migrations')->get();
print_r($rows);
这列出了所有已完成的迁移。我正在使用内存中的 sqlite 数据库进行测试。
我想知道迁移是否是 运行 异步的并且它们在我的代码 运行 时还没有全部完成?或者如果迁移在某处悄无声息地失败了?
我已经在这里待了几个小时了,不知道发生了什么。
*UPDATE 在上述迁移之后我有一个 运行s 的迁移,我确认后续迁移成功。因此,只有这一迁移以某种方式悄无声息地失败了。
我发现了问题。这是因为 sqlite 在一个 table 调用中没有多个添加列语句的荒谬限制,如 here.
所示
当我如下所示分离出迁移时,它起作用了:
Schema::table('loan_details', function(Blueprint $table){
$table->integer('start_month')->unsigned()->after('interest_only')->default(0);
});
Schema::table('loan_details', function(Blueprint $table){
$table->decimal('balloon_percent',4,3)->after('term')->nullable();
});
Schema::table('loan_details', function(Blueprint $table){
$table->integer('balloon_month')->after('balloon_percent')->nullable();
});
Schema::table('loan_details', function(Blueprint $table){
$table->dropColumn('ordinal_rank');
});
检查 SQLite 数据库记录 here
还有许多其他有用的内置点命令 -- 请参阅文档
http://www.sqlite.org/sqlite.html,sqlite3 的特殊命令部分。
另外,检查数据库模式
我的单元测试最近开始失败。我收到此错误:
PDOException: SQLSTATE[HY000]:
General error: 1 table loan_details has no column named start_month
发生的行,我有这个代码:
$loan = LoanDetails::create(['loan_percentage' => .8,
'loan_product_id' => 1,
'interest_rate' => .5,
'start_month' => 0,
'term' => 120,
'fixed_finance_fee' => 0,
'variable_finance_Fee' => 0,
'valid_from' => '2015-01-01'
]);
如果我注释掉 "start_month" 行,那么它在逻辑上是有效的。
在我的单元测试设置中,我 运行 所有迁移(大约 80)。
我有一个看起来像这样的迁移:
Schema::table('loan_details', function(Blueprint $table){
$table->integer('start_month')->unsigned()->after('interest_only')->default(0);
$table->decimal('balloon_percent',4,3)->after('term')->nullable();
$table->integer('balloon_month')->after('balloon_percent')->nullable();
$table->dropColumn('ordinal_rank');
});
所以,我想知道是否所有的迁移都没有 运行ning 所以我 运行 这个代码:
$rows = DB::table('migrations')->get();
print_r($rows);
这列出了所有已完成的迁移。我正在使用内存中的 sqlite 数据库进行测试。
我想知道迁移是否是 运行 异步的并且它们在我的代码 运行 时还没有全部完成?或者如果迁移在某处悄无声息地失败了?
我已经在这里待了几个小时了,不知道发生了什么。
*UPDATE 在上述迁移之后我有一个 运行s 的迁移,我确认后续迁移成功。因此,只有这一迁移以某种方式悄无声息地失败了。
我发现了问题。这是因为 sqlite 在一个 table 调用中没有多个添加列语句的荒谬限制,如 here.
所示当我如下所示分离出迁移时,它起作用了:
Schema::table('loan_details', function(Blueprint $table){
$table->integer('start_month')->unsigned()->after('interest_only')->default(0);
});
Schema::table('loan_details', function(Blueprint $table){
$table->decimal('balloon_percent',4,3)->after('term')->nullable();
});
Schema::table('loan_details', function(Blueprint $table){
$table->integer('balloon_month')->after('balloon_percent')->nullable();
});
Schema::table('loan_details', function(Blueprint $table){
$table->dropColumn('ordinal_rank');
});
检查 SQLite 数据库记录 here
还有许多其他有用的内置点命令 -- 请参阅文档 http://www.sqlite.org/sqlite.html,sqlite3 的特殊命令部分。
另外,检查数据库模式