我正在尝试使用 Laravel Migration 创建 SQL 表,但它不让我使用.
I am trying to use Laravel Migration to create SQL tables but it won't let me.
这里是错误:
SQLSTATE[42S01]:基表或视图已经存在:1050 表'mytable' 已经存在
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'mytable' already exists
这是我的代码:
Schema::create('mytable', function (Blueprint $table) {
$table->increments('id');
$table->foreign('othertable_id')
->references('id')->on('othertable')
->onDelete('cascade');
$table->string('variable');
$table->timestamps();
});
}
{
Schema::drop('mytable');
}
我还检查了其他迁移是否称为mytable",但它们不是,所以我不确定这是从哪里来的.
I have also checked if other migrations are called "mytable" but they are not, so I am not sure where this come from.
我尝试了以下方法:
第一次
php artisan migrate:refresh
这给了我一个错误
然后我删除了整个数据库并使用:
And then I deleted the entire database altogheter and used:
php artisan migrate
还是报错
do composer dump
,手动从数据库中删除表,并删除要从中删除的表的迁移条目迁移表并再次重新运行迁移以查看会发生什么.
do composer dump
, remove the table manually from the database and also remove the migration entry for the the table you want to remove from the migration table and rerun the migration again to see what happens.
这篇关于Laravel 不允许我迁移表,因为它已经存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!