【发布时间】:2019-06-03 00:09:53
【问题描述】:
所以我环顾四周,发现了一些关于如何解决此问题的建议,但我仍然无法使其正常工作。
所以我在迁移文件夹中创建了一个名为 social.php 的文件。
并在其中添加了此代码。但是当我执行命令时
php 工匠迁移
我没有什么可以迁移作为回报。
请注意,我执行此命令来创建 Auth(users table 和 password reset 迁移成功),然后在我完成它们后,我将它们备份并从迁移文件夹中删除它们。
我创建了 social.php,然后这一切都发生了。
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSocialTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('social', function (Blueprint $table) {
$table->increments('id');
$table->string('userid');
$table->string('sname');
$table->string('sud');
$table->string('surl');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('social');
}
}
【问题讨论】:
-
所以你在运行迁移后删除了默认迁移?尝试删除数据库中的迁移表,运行
composer dump并重试。如果失败,请删除迁移并在命令行上使用 artisan 创建它:php artisan make:migration create_social_table。 -
试过了,我也试过 composer dump-autoload 但还是没有
-
更新了上面的评论。
-
您是否运行此程序并最初失败?无论如何,迁移脚本仍将更新迁移表。如果您将
Schema::create包装在 try/catch 中,并在 catch 失败时回滚,这应该允许您再次执行此操作 -
我的错误是手动而不是使用命令。让它工作。感谢您的宝贵时间