Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Migrate:refresh does not work after deleting migration #2105

Closed
fharbe opened this Issue Aug 15, 2013 · 11 comments

Comments

Projects
None yet
9 participants
@fharbe
Copy link

fharbe commented Aug 15, 2013

I can't run migrate:refresh (with or without --seed) or migrate:reset anymore after deleting a migration file.

Running composer dump-autoload or composer update won't help either.

Any ideas?

Here's the code:

$ artisan migrate:refresh
PHP Fatal error:  Class 'AddCommentsToDevicesTable' not found in /Users/florianharbecke/Sites/trackle/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php on line 301
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'AddCommentsToDevicesTable' not found","file":"\/Users\/florianharbecke\/Sites\/trackle\/vendor\/laravel\/framework\/src\/Illuminate\/Database\/Migrations\/Migrator.php","line":301}}

Any ideas on how to fix the issue?

@taylorotwell

This comment has been minimized.

Copy link
Member

taylorotwell commented Aug 15, 2013

If you deleted the file you should delete the matching row from the migrations table in your DB. Don't delete a migration without doing migrate:reset first.

@fharbe

This comment has been minimized.

Copy link
Author

fharbe commented Aug 21, 2013

Thanks for the help! I figured it out :)

@dieguisherrera

This comment has been minimized.

Copy link

dieguisherrera commented Aug 25, 2014

Yeap this works

@jagroop

This comment has been minimized.

Copy link

jagroop commented Mar 1, 2016

thanks

@mnrafg

This comment has been minimized.

Copy link

mnrafg commented Nov 22, 2016

Also you have to run composer dump-autoload command from your terminal after removing the migration file to automatically update vendor/composer/autoload_classmap.php and vendor/composer/autoload_static.php composer autoload files.

@langocthach

This comment has been minimized.

Copy link

langocthach commented Dec 2, 2016

I deleted migration file first, then delete the migrations table in database, and run composer dump-autoload. But still have errors like this:

[ErrorException]
Undefined index: 2016_12_01_044011_create_reward_request_inboxes_table

I use Laravel 5.3 and PHP 7

@mnrafg

This comment has been minimized.

Copy link

mnrafg commented Dec 5, 2016

@langocthach: as @taylorotwell says you must first do: $ php artisan migrate:reset then delete the migration, after that you can follow $ composer dump-autoload.

@joyhanawa

This comment has been minimized.

Copy link

joyhanawa commented Feb 15, 2017

If you are a newb like me, and accidentally delete the migration before running reset, you will need to go into the database and remove the corresponding record from the table migrations (make sure to apply your changes so that the index is also updated, or you will get an index error).

@ligexiao

This comment has been minimized.

Copy link

ligexiao commented Apr 17, 2017

@taylorotwell thanks,it works for me !

@codedgift

This comment has been minimized.

Copy link

codedgift commented Jun 25, 2017

i made a mistake i then remove a particular field from the migration. i run php artisan migrate:refresh so as to apply the changes but i got an error. what can i do. that's the error i got below
[ErrorException]
Undefined index: 2016_12_01_044011_create_tasks_table

@codedgift

This comment has been minimized.

Copy link

codedgift commented Jun 25, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.