php artisan:rollback error in laravel 5.3

559
January 07, 2017, at 7:10 PM

I tried building a database where I forgot to place the index of the table. Now I'm trying to rollback the migration but its not working out. It is throwing some error

[ErrorException] Undefined index: 2017_01_06_195028_create_users_themes_table

Now I tried deleting it manually so I deleted the migration file from the database folder and then did composer dump-autoload, and then did rollback it is still showing same error. Also when this didn't happened I tried placing index in the table through phpmyAdmin, it ain't helped! Still i deleted the table manually and tried doing composer dump-autoload and rollback it still has same error.

Help me out with this.

Answer 1

You can backup DB data (if any), drop DB and create it again and run php artisan migrate command. It's the easiest way to fix this I guess.

Another thing you could try is to delete last batch from migrations table and drop tables from last batch and run php artisan migrate

Answer 2

When you do php artisan migrate, migration table is created and it records the order of the migration you run. And when you rollback the list get cleared in the order of rollbacks..

In your case since you got an error the record corresponding to your migration probably still in the migration table.

Now if you wish to update your migration file and migrate again, you needs to manually clear the corresponding record from the migration table. Most probably it would be the last record in the migration table.

Clear out that record, fix your migration file and run your migration. You should be good to go.

READ ALSO
My Website Search does not echo any results

My Website Search does not echo any results

I have made a Website Search and it does not echo any results but it shows how many results there are

142
Laravel - Getting all records not just the first and putting together?

Laravel - Getting all records not just the first and putting together?

I have tried asking this question to everyone but nobody can see why I am trying to do it or why its not working but I will try my best to explain it properly this time

178
how to make group of two array with given array in php?

how to make group of two array with given array in php?

i have one array and elements like:-

217
how to edit angular translate file using php

how to edit angular translate file using php

I am developing a classified website using laravel and angularjsWe can change the language from user side

284