当我想使用migrate
和migrate:fresh
命令迁移我的迁移时,我得到This Error
这些是我的迁移:
public function up()
{
Schema::create('notes', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id')->unsigned()->index();
$table->integer('card_id')->unsigned()->index();
$table->text('body');
$table->timestamps();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('card_id')->references('id')->on('card')->onDelete('cascade');
});
}
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('username');
$table->string('email');
$table->string('password');
$table->timestamps();
});
}
public function up()
{
Schema::create('cards', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->timestamps();
});
}
我只是尝试过任何事情,我不知道我该怎么办[我是laravel的初学者]
答案 0 :(得分:0)
您需要更改迁移文件中的日期和时间,因此在cards
表之前创建了users
和notes
表。
答案 1 :(得分:0)
首先确保在users
之前创建notes
和$table->foreign('card_id')->references('id')->on('card')->onDelete('cascade');
。
另外代替:
$table->foreign('card_id')->references('id')->on('cards')->onDelete('cascade');
使用:
card
(您有cards
而不是let action1 = SKAction.fadeIn(withDuration: TimeInterval(0.2))
let action2 = SKAction.wait(forDuration: TimeInterval(0.4))
let action3 = SKAction.fadeOut(withDuration: TimeInterval(0.1))
let action4 = SKAction.perform(self.blinkLightByOrder, onTarget: UFOSprite._ufoBase)
let action5 = SKAction.sequence([action1, action2, action3, action4])
currentLight.run(action5)
)
答案 2 :(得分:0)
基本上,您的notes表是在users表之前创建的,因此是外键错误。它可以找到用户表,因为它还不存在(还)
Laravel按顺序迁移,所以有2个黑客可以解决这个问题: