Laravel 5.1-迁移错误 [英] Laravel 5.1 - Migration Error
问题描述
我试图创建一个新表,但是当我添加Schema::create()
部分时,我从用户复制/粘贴了该表,因此我的原始用户表和新表都迁移为Schema::create('users')
,并遇到了问题,因为有2个同名桌子.当我意识到问题后,我将其修复,但由于现在无法使用php artisan migrate:reset
和php artisan migrate:refresh
删除表,因为现在已经有两个具有相同名称的表. (因此,我也无法回滚.)
I was trying to create a new table, but when I was adding Schema::create()
part, I copy/pasted it from users so both my original users table, and my new table migrated as Schema::create('users')
and it ran into a problem as there was 2 tables with same name. When I realised the problem, I fixed it but as I cannot drop the tables now with php artisan migrate:reset
and php artisan migrate:refresh
because there are two tables with the same name already now. (Thus, I cannot rollback either).
我的数据库名称是原始的Homestead.
My DB name is Homestead as original.
我得到的错误:
[Illuminate \ Database \ QueryException] SQLSTATE [42S02]:找不到基表或视图:1051未知表'homestead.users'(SQL:删除表
users
)
[Illuminate\Database\QueryException] SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'homestead.users' (SQL: drop table
users
)
[PDOException] SQLSTATE [42S02]:找不到基表或视图:1051未知表'homestead.users'
[PDOException] SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'homestead.users'
我不确定如果手动登录vagrant ssh
并放下&手动创建表:
And I am not sure if I mess everything up if I manually log into vagrant ssh
and drop & create tables manually with:
mysql> drop database Homestead;
mysql> create database Homestead;
推荐答案
在@ Jamesking56的评论之后,我使用了:
Following @Jamesking56's comment, I used:
mysql> drop database homestead;
mysql> create database homestead;
php artisan migrate
这解决了我的问题.
这篇关于Laravel 5.1-迁移错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!