5

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!!!

Garret Corbett
  • 133
  • 1
  • 6
  • Can you provide a list of your migration files? – Elliot Feb 23 '17 at 17:57
  • Yes of course @Kurucu Here are the current files in my migrations folder: database\migrations\2014_10_12_000000_create_users_table database\migrations\2014_10_12_100000_create_password_resets_table – Garret Corbett Feb 23 '17 at 19:04
  • a) When you say change the table in the .env file, I assume you mean database? b) Are you looking at the same database as the one in the .env file; i.e. are you seeing old tables because you are looking at the wrong database? Try deleting all the tables and re-running the migration. – Elliot Feb 27 '17 at 07:34

2 Answers2

8

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
Garret Corbett
  • 133
  • 1
  • 6
  • For me, for some reason php artisan migrate was looking at another laravel project's database in XAMPP. This is the day I learned to use unique passwords for projects, I would have hated to 'drop' the users table in my other project. As it is, I had to `php artisan cache:clear` and `php artisan config:cache` a couple times, then `php artisan migrate` worked. – AWP Jan 08 '21 at 20:31
1

enter image description here

enter image description here

enter image description here

php artisan migrate:refresh php artisan migrate

ExpertWeblancer
  • 1,368
  • 1
  • 13
  • 28