php artisan:rollback error in laravel 5.3

237 views Asked by At

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.

3

There are 3 answers

0
Nitish Kumar On BEST ANSWER

I forgot to mention that I'm having my migration files in different folder so everytime I'm doing a php artisan migrate rollback I need to specify the path of those migration file that is why it is showing undefined Index error.

0
Gayan On

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.

0
Alexey Mezenin On

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