问题描述
我已经使用 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 migrate --force 和 php artisan migrate: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) 中读取 error msg 并查看 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 中进行迁移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!