Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel默认用户表_Php_Laravel - Fatal编程技术网

Php Laravel默认用户表

Php Laravel默认用户表,php,laravel,Php,Laravel,我使用Laravel5.2并希望更改默认用户表的列。我写 在CreateUsersTable中 public function up() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->uniq

我使用Laravel5.2并希望更改默认用户表的列。我写 在CreateUsersTable中

   public function up()
   {
    Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('email')->unique();
        $table->string('password');
        $table->rememberToken();
        $table->timestamps();
    });

    Schema::table('users', function ($table) {
        $table->string('role');
        $table->string('info');
        $table->string('age');
        $table->string('hobies');
        $table->string('job');
    });
    }
我在GitBash中运行了这些命令,但用户表没有改变

    php artisan migrate:refresh
    php artisan migrate

如何解决此问题?

您应该在运行
php artisan migrate
命令后运行
composer dumpauto-o
,以注册新的迁移,以便回滚它们

试试看。如果不起作用,请尝试删除所有表,包括
migrations
,然后运行以下命令:

php artisan migrate:install

您应该在运行
php artisan migrate
命令后运行
composer dumpauto-o
,以注册新的迁移,以便回滚它们

试试看。如果不起作用,请尝试删除所有表,包括
migrations
,然后运行以下命令:

php artisan migrate:install

您只需更改它在
Schema::create
中的内容,并删除您的
Schema::table

然后,您需要实现tour
down()
mehod并添加
Schema::drop('users')以便在运行
migrate:refresh
时删除表


您可以阅读laravel文档中的“数据库迁移”以了解更多详细信息。

您只需更改
Schema::create
中的内容并删除
Schema::table

然后,您需要实现tour
down()
mehod并添加
Schema::drop('users')以便在运行
migrate:refresh
时删除表


您可以阅读laravel文档中的“数据库迁移”了解更多详细信息。

创建新的迁移文件并执行类似操作

public function up() {
    DB::statement('ALTER TABLE user ADD some_field INT');// your query here
}

php artisan migrate

创建新的迁移文件并执行如下操作

public function up() {
    DB::statement('ALTER TABLE user ADD some_field INT');// your query here
}

php artisan migrate

删除第一条语句,只保留最后一条。
然后运行php artisan migrate:refresh

删除第一条语句,只保留最后一条语句。 然后运行php artisan迁移:刷新