Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I broke my Laravel framework with migration renaming

Tags:

I had a good working Laravel structure with database migrations and seeding. But I wanted my migration file,classes,db table be renamed to CreateOrganizationsTable instead of CreateOrganisationsTable

So I changed the migration filename, all classes and routes.

But when I execute php artisan migrate:reset in my Homestead box, I get the following error:

PHP Fatal error: Class 'CreateOrganisationsTable' not found in /home/vagrant/Code/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php on line 299

Artisan created some link I'm unable to fix at the moment.

like image 271
moasking Avatar asked Aug 04 '14 08:08

moasking


People also ask

Can I rename migration in Laravel?

Yes, you can name them however you want, but they will run in alphabetical order (which is why laravel timestamps them). Also you can change a migrations name after the fact (you've already run the migration).

Can I delete migration file Laravel?

If you've only created the migration and you've not executed the php artisan migrate command, all you would need to do to remove the migration is to delete the file. You could do that via your text editor or the command line with the rm command.

How can I migrate to Laravel again?

IF you want to re-migrate all the database, you can simply do: php artisan migrate:refresh . IF you want to make sure your database to be clean with your latest changes, you can drop your entire database tables and do php artisan migrate again. Also, you can try php artisan migrate --seed if you have any seeder.


2 Answers

As Morale mentioned you must reset or rollback to a point before your new migration or make the changes manually. I knew this but was still getting the problem after changing only the timestamps to have the migrations run in a different order.

You must run composer dump-autoload even if you didn't change the class name.

like image 57
DutGRIFF Avatar answered Oct 02 '22 05:10

DutGRIFF


Don't forget to also rename the class inside the file

like image 38
code511788465541441 Avatar answered Oct 02 '22 05:10

code511788465541441