Sazrit Mustafa
Sazrit Mustafa

Reputation: 145

Laravel migration undefined index

I am using Laravel 5.3.I deleted one of my migration files name 'feature' and everything related to it very carefully like its id from other tables etc.then i manually deleted the table from database.But now while i'm running the command "php artisan migrate:refresh".It's showing error exception with 'undefined index:***_create_features_table'.And when I'm running just 'php artisan migrate'.it shows that it was successful and all the tables successfully appear in the database.but then when i run migrate:refresh all the table disappears.what should i do to completely delete the migration file?

Upvotes: 8

Views: 27062

Answers (6)

Faran
Faran

Reputation: 138

in the migration just add $table->index(['column Name 1',''column Name 1']);

Upvotes: 0

With my case, I forgot to do the Laravel migrate before running Infyomlabs to create scaffold! So one of the reasons for "Undefined index" is that the table is not there yet.

Upvotes: -1

Adam Kozlowski
Adam Kozlowski

Reputation: 5896

If you have Undefined index error and your migration was made with --path option, then add to your ModuleServiceProvier boot() method:

$this->loadMigrationsFrom(base_path('database/migrations/directory-name'));

Upvotes: 0

tyoc213
tyoc213

Reputation: 1253

Try check that you have the correct migrations first

php artisan migrate:status

Then you can try something like

php artisan migrate:refresh --step=1

And check again the status.

Upvotes: 1

Sazrit Mustafa
Sazrit Mustafa

Reputation: 145

Here is what I did.I cleared all the data from the database including all tables and then ran 'php artisan migrate'..that is how i made it work..But i am looking for a better solution which will not need to delete everything from the database.

Upvotes: 4

Manish
Manish

Reputation: 3643

Try this.

First Manually delete the migration file under app/database/migrations/my_migration_file_name.php

Reset the composer autoload files: composer dump-autoload

Modify your database: Remove the last entry from the migrations table

Upvotes: 33

Related Questions