如何在laravel 5.5中进行迁移? [英] How can I do a migration in laravel 5.5?

查看:72
本文介绍了如何在laravel 5.5中进行迁移?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 laravel 5.5 创建了Auth项目,并创建了新的迁移,并且在迁移时收到此错误消息:

I've created an Auth project with laravel 5.5 and created new migration and when I migrate I receive this error msg:

在Connection.php第647行中:

In Connection.php line 647:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists
(SQL: create table `users` (
      `id` int unsigned not null auto_increment primary key,
      `name` varchar(255) not null,
      `username` varchar(255) not null,
      `email` varchar(255) not null,
      `password` varchar(255) not null,
      `remember_token` varchar(100) null,
      `created_at` timestamp null,
      `updated_at` timestamp null,
      `role` int not null
      ) default character set utf8mb4 collate utf8mb4_unicode_ci
)

在Connection.php第449行中:

In Connection.php line 449:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists

我尝试php artisan migration --force和php artisan migration:rollback

i try php artisan migrate --force and php artisan migrate:rollback

并尝试删除所有表格并再次迁移,仍然会遇到此错误

and try to drop all tabels and migrate it again and still ahve this error

推荐答案

在读取CMD(DOS)中的错误消息并检查laravel文档后

after reading error msg in CMD (DOS) and check laravel documentation

长度错误,我不知道是否有人之前看到过此错误,但是当我编辑其工作长度时

error in length i dont know if any one see this error before or not but when i edit length its work

我编辑3次迁移,如下所示:-

i edit 3 migration as below :-

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

现在是

        Schema::create('users', function (Blueprint $table) {
        $table->increments('id')->autoIncrement();
        $table->string('name',200);
        $table->string('username',50)->unique();
        $table->string('email',100)->unique();
        $table->string('password',50);
        $table->string('role',50);
        $table->rememberToken();
        $table->timestamps();

    });

第2个是

 Schema::create('password_resets', function (Blueprint $table) { $table->string('email')->index(); $table->string('token'); $table->timestamp('created_at')->nullable(); });

现在是它的:-

        Schema::create('passwordreset', function (Blueprint $table) {
        $table->string('email',200)->index();
        $table->string('token',200);
        $table->timestamp('created_at')->nullable();
    });

第3个是:-

3- Schema::create('tweets', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id')->unsigned()->index(); $table->text('text'); $table->timestamps(); });

现在是它的:-

        Schema::create('tweets', function (Blueprint $table) {
        $table->increments('id')->autoIncrement();
        $table->string('user_id',50)->index();
        $table->string('twetts',255);
        $table->timestamps();
    });

这篇关于如何在laravel 5.5中进行迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆