Laravel:没什么可迁移的

问题描述 投票:2回答:4

所以我环顾四周,找到了几个如何解决这个问题的建议,但我仍然无法让它发挥作用。

所以我在我的迁移文件夹中创建了一个名为social.php的文件。

并在其中添加此代码。但是当我执行命令时

php工匠迁移

我没有什么可以作为回报迁移。

请注意,我执行此命令来创建Auth(users tablepassword 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');
    }
}
php laravel migrate
4个回答
2
投票
  1. 您是否通过php artisan make:migration创建了迁移文件,或者您是手动创建的?
  2. 如果您通过命令执行此操作,只需从数据库中删除受尊重的表,并删除迁移文件,然后运行php artisan migrate

在终端中使用此命令进行迁移:

php artisan make:migration create_social_table

如果您正在寻找带迁移的模型

php artisan make:migration create_social_table -m

2
投票

要创建迁移,请使用php artisan make:migration Artisan命令:

php artisan make:migration create_tablename_table

新迁移将放在database/migrations目录中。

之后,要运行所有未完成的迁移,请执行迁移Artisan命令:php artisan migrate


1
投票

请在迁移文件夹中创建新文件夹,例如test,并将您的(social.php)文件放在test文件夹中并在终端或cmd中运行以下命令

php artisan migrate --path=database/migrations/test/

1
投票

在控制台中运行此命令:

php artisan make:migration create_tablename_table
© www.soinside.com 2019 - 2024. All rights reserved.