【问题标题】:Laravel quickstart migration doesn't workLaravel 快速入门迁移不起作用
【发布时间】:2014-07-01 22:47:24
【问题描述】:

我今天早上一直在做 Laravel 的快速入门,但我在迁移部分遇到了一些问题。我在 Windows 8.1 上运行它,使用 XAMPP 的最后一个版本、Laravel 的最后一个版本和 windows 的 CMD 命令。

我已经创建了迁移文件“users”,您可以在下一段代码中看到:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration {

/**
* Run the migrations.
*
* @return void
*/
public function up()
{
    Schema::create('users', function(Blueprint $table) {
        $table->integer('id', true);
        $table->string('name');
        $table->string('username')->unique();
        $table->string('email')->unique();
        $table->string('password');
        $table->timestamps();
        $table->softDeletes();
    });
}

/**
 * Reverse the migrations.
 *
 * @return void
 */
public function down()
{
    Schema::drop('users');
}

}

迁移表已创建,我正在使用下一个创建用户表:

php artisan migrate

这就是答案:

Aplication in production!

Do you really wish to run this command? yes
Nothing to migrate.

(我无法显示图片,因为这是我的第一个问题)

希望你能帮助我,我想继续尝试这个框架,但我不知道如何解决这个问题,已经谷歌搜索了一个小时,但没有任何效果。

【问题讨论】:

标签: php laravel


【解决方案1】:

问题是迁移已经运行。这就是为什么它说 'Nothing to migrate'。要进行验证,请检查表 migrations 的内容,您会看到有一个用于用户表迁移的条目。

要回滚(撤消)上次迁移并再次运行它,请使用以下命令:

php artisan migrate:rollback
php artisan migrate

要回滚(撤消)并再次运行所有迁移,请使用以下命令:

php artisan migrate:reset
php artisan migrate

与最后两个等效的一个命令是:

php artisan migrate:refresh

顺便说一句,如果你想摆脱警告 生产中的应用程序!你真的要运行这个命令吗?你必须configure your environment

【讨论】:

    【解决方案2】:

    已经使用 MySQL 服务器解决了它并避免使用 phpMyAdmin,因为使用迁移命令它对我不起作用。

    【讨论】:

      【解决方案3】:

      如果迁移文件夹中有超过所需的迁移文件,它可能无法工作并显示错误消息“参数过多”。

      所以当完成创建表然后删除已经完成的表。

      【讨论】:

        猜你喜欢
        • 2013-05-29
        • 2021-06-06
        • 2016-08-25
        • 2018-11-15
        • 1970-01-01
        • 2021-01-20
        • 1970-01-01
        • 1970-01-01
        • 2013-12-21
        相关资源
        最近更新 更多