尝试在laravel中迁移,此错误弹出。我认为错误可能是我在另一个相同问题答案中发现的bigInteger类型。请参考将bigInteger更改为bigIncrements,但是我没有得到关于类型约束的另一个错误。
代码
divs = soup.find_all('div', {'id': 'facts'})
for div in divs:
fact_li = div.find_all('li')
for fact in fact_li:
spans = fact.find_all('span', {'class': 'description'})
for span in spans:
a = fact.find_all('a')
result_list.append(a)
错误
public function up()
{
Schema::create('categories_products', function (Blueprint $table) {
$table->bigInteger('category_id')->unsigned()->index();
$table->bigInteger('product_id')->unsigned()->index();
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
$table->foreign('product_id')->references('id')->on('products')->onDelete('cascade');
});
}
谢谢。
答案 0 :(得分:3)
很难给出明确的答案,而无需查看目标表上该关系的列定义。类型需要匹配。因此,如果您在id字段中使用bigIncrements(),则unsignedBigInteger()
或bigInteger()->unsigned()
都应作为外键的类型,但是,如果您将increments
用作ID,则外键必须为unsignedInteger()
或integer()->unsigned()