Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel 5.4 migration issue

I am having a very weird issue when running

php artisan migrate

on a new installation of Laravel 5.4 on a local XAMPP server with php 7.1.1.

What it is doing is creating a migrations and users table, the default tables in older versions of Laravel. What is should be creating is a users table and a passwords reset table, the new default tables. My env file is correct because I am connecting to the database correctly but then if I change the table I am connecting to in the env file it is not updating.

To me, it seems like the command is simply not running on the correct migrations folder in the application. This is a brand new machine with a fresh install of XAMPP and Laravel so I am very confused as to why this is happening. Any help would be much appreciated!!!

like image 536
Garret Corbett Avatar asked Feb 23 '17 16:02

Garret Corbett


1 Answers

I was finally able to get this to work so I wanted to answer the question to explain what I did.

This first step may not be required for you but it was for me. Once again, here is what I was using: Laravel 5.4 on a local XAMPP server with php 7.1.1

-First I needed to edit app>Providers>AppServiceProvider.php https://laravel-news.com/laravel-5-4-key-too-long-error -Add this line to the top, under the other use include: use Illuminate\Support\Facades\Schema; -In the boot() function add this code: Schema::defaultStringLength(191);

-After that I needed to run php artisan migrate, to create the default tables from the migrations. For some reason, a reason I could not find with any amount of research, this creates the old tables from an unknown source. After that I needed to edit the create_users_table migration, delete the users and migrations table that were created in the database, then rerun php artisan migrate. Like I said, I am not sure why this has to be done but it will get it to work.

Also, remember to run these commands before running php artisan migrate the last time just to be safe:

php artisan cache:clear

php artisan config:cache
like image 177
Garret Corbett Avatar answered Sep 18 '22 23:09

Garret Corbett