【问题标题】:How to customize laravel user Migration to new如何自定义 laravel 用户迁移到新的
【发布时间】:2018-06-10 10:37:32
【问题描述】:
public function up()
{
    Schema::create('users', function (Blueprint $table) {
        $table->increments('id');
        $table->string('name');
        $table->string('last_name')->nullable();
        $table->string('phone_number')->nullable();
        $table->text('Biography')->nullable();
        $table->string('address')->nullable();
        $table->string('photo')->nullable();
        $table->string('facebook_link')->nullable();
        $table->string('twitter_link')->nullable();
        $table->string('youtube_link')->nullable();
        $table->string('email')->unique();
        $table->string('password');
        $table->rememberToken();
        $table->timestamps();
    });
}

我想将用户更改为另一个名称,但不能,并且迁移不起作用。

【问题讨论】:

标签: php laravel migration


【解决方案1】:

如果你想rename the table,你可以用这个代码创建一个新的迁移:

Schema::rename('users', 'some_other_table_name');

然后运行composer duphp artisan migrate 命令。

或者,您可以通过回滚此迁移 php artisan migrate:rollback 来重新创建表,如果您在 down() 方法中有此行,则它将起作用:

Schema::drop('users');

更改表名:

Schema::create('some_other_table_name', function (Blueprint $table) {

然后运行php artisan migrate

https://laravel.com/docs/5.5/migrations

【讨论】:

  • 但由于迁移和身份验证无法正常工作,重命名后无法迁移用户表
  • @Najibjamshidi 你问如何重命名表格,我已经回答了。要为身份验证系统使用不同的表,只需更改config/auth.php中的提供者
猜你喜欢
  • 2021-02-28
  • 2020-09-20
  • 2011-02-15
  • 2020-03-02
  • 2019-01-25
  • 1970-01-01
  • 2021-12-31
  • 1970-01-01
  • 2017-08-05
相关资源
最近更新 更多