senty senty - 1 month ago 15
MySQL Question

Laravel 5.1 - Migration Error

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).

My DB name is Homestead as original.

The errors I am getting:


[Illuminate\Database\QueryException]
SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'homestead.users' (SQL: drop table
users
)

[PDOException]
SQLSTATE[42S02]: Base table or view not found: 1051 Unknown table 'homestead.users'


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;

Answer

Following @Jamesking56's comment, I used:

mysql> drop database homestead;

mysql> create database homestead;

php artisan migrate

and Solved my Problem.