I delete a migration file manually. Now I try to run the migrations with:
php artisan migrate:refresh
I get an error:
[ErrorException]
include(C:\xampp\htdocs\NightClubs/database/migrations/2014_10_12_000000_cr
eate_users_table.php): failed to open stream: No such file or directory
This is the name of the migration file that I deleted. What to do?
The schema for migrations records the names of the files run through the artisan migrate command.
If you experience errors after deleting a migration class file, simply delete the record from the migrations table. If you have the liberty, completely dismantle the database and start from scratch.
Related
I have created by a mistake 2 migrations in my laravel project, using the php artisan make:migration command called 2018_03_30_075929_drop_products_tags_table and 2018_03_30_075242_create_products_tags_table and then i have deleted the files.
Now everything i run the command php artisan migrate:refresh I am get this error
Migration not found: 2018_03_30_075929_drop_products_tags_table
Migration not found: 2018_03_30_075242_create_products_tags_table
...
And i tried to run php artisan migrate:reset, but I am getting the same error. How can I fix this, because it is driving me insane :(
This is you have some migrations in your database
go to your database delete the migrations table manually.
then you can create a migration table in your database
php artisan migrate:install
This will create a new migration table in your database.
then you can run
php artisan migrate
Hope this helps
Delete tables from database
Delete migrations name from migrations table
In this scene:
Delete product_tags table. Then, delete
2018_03_30_075929_drop_products_tags_table,
2018_03_30_075242_create_products_tags_table
rows from migration tables.
You can delete all tables from database and migrate them again by this command:
php artisan migrate:fresh
php artisan make:migration create_batles_table
Created Migration: 2017_04_01_123218_create_batles_table
php artisan make:migration create_batles_table
[InvalidArgumentException]
A CreateBatlesTable migration already exists.
---------------------File deleted by me-----------------------------
php artisan make:migration create_batles_table
[ErrorException]
include(/home/lubuntu/Desktop/work/git/lara/database/migrations/2017_04_01_123218_create_batles_table.php): fail
ed to open stream: No such file or directory
Now using another name "newbatles" instead of "batles"
php artisan make:migration create_newbatles_table
Created Migration: 2017_04_01_123343_create_newbatles_table
php artisan make:migration create_newbatles_table
[InvalidArgumentException]
A CreateNewbatlesTable migration already exists.
-----------File deleted by me--------------
php artisan make:migration create_newbatles_table
[ErrorException]
include(/home/lubuntu/Desktop/work/git/lara/database/migrations/2017_04_01_123343_create_newbatles_table.php): f
ailed to open stream: No such file or directory
Why I can't recreate migrations with same name in Laravel 5.4?
When changing something in migrations always run these commands:
php artisan cache:clear
php artisan view:clear
php artisan route:clear
composer dump-autoload
It will clear all old stuff and run smoothly!
Update:
But remember: the table name must be unique inside that database...it's like a name for folder on a hard drive. You can't have more than one table with that specific name!
Did you delete it from migration table too ?
If not please run
php artisan migrate:refresh
to refresh the table.
but be aware that in this way you will clean all the database tables!
so if you don't want to do so, just delete the migration from the database directly.
i have created a table from command
php artisan make:migration create_info_table --create=info
then i delete it for a cause from migration folder , now when i again wanted to create the table , the command console showing
[ErrorException]
include(C:\xampp\htdocs\laravel\vendor\composer/../../database/migrat
016_09_01_082120_create_info_table.php): failed to open stream: No su
e or directory
how can i solve this,
in laravel for a table must create a model and best way is:
php artisan make:model Info -m
Try running composer dump-autoload
have you deleted the migration file?
I have met the similar problem, i solved by delete the migration file and rebuild it again using the command line, and then try to migrate, it works.
I like to use artisan migrate to rollback an migration. But when i excecute:
php artisan migrate:rollback
I get the following error message:
I have renamed the file, for reordering, befor I did the migration. In migration database is the correct file listed 2015_07_10_000007_create_einlagerungen_table.
You need to run composer dump-autoload if you have renamed the file so that composer can find it.
In my Application, when I run php artisan migrate:make create_location_user_table, then delete the generated file (doesn't matter if I delete the line created in vendor/composer/autoload_classmap.php, the php artisan migrate:refresh command throws an error:
include(<path_to_project>/database/migrations/2015_06_21_105357_create_location_user_table.php): failed to open stream: No such file or directory
After running commands to get rid of the faulty autoload entry, I get an exception. The commands I tried are: composer update, composer dump-autoload, php artisan clear-compiled, php artisan optimize.
PHP Fatal error: Class 'CreateLocationUserTable' not found in <path_to_project>\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php on line 323
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'CreateLocationUserTable' not found
Go into your mysql database manually (PHPMyAdmin) and remove the migrations table. With the steps you've taken above and doing this should solve your issue