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.
Related
Docker 18.09.2
Mysql 5.7
Laravel 5.7
PHP 7.125
I am new at Laravel and I have a problem When I use php artisan db:seed, this error appeared:
include(/var/www/laravel_app/vendor/composer/../../database/seeds/AdminsTableSeeder.php):
failed to open stream: No such file or directory
at /var/www/laravel_app/vendor/composer/ClassLoader.php:444
440| * Prevents access to $this/self from included files.
441| */
442| function includeFile($file)
443| {
> 444| include $file;
445| }
446|
I have no idea why does it happens.
There was no error when I used php artisan migrate.
I have already tried php artisan migrate --seed and php artisan migrate:refresh --seed.
Can anyone please help me?
You should try using composer dump-autoload.
From this answer in SO:
Basically, because Composer can't see the migration files you are
creating, you are having to run the dump-autoload command which won't
download anything new, but looks for all of the classes it needs to
include again. It just regenerates the list of all classes that need
to be included in the project (autoload_classmap.php), and this is why
your migration is working after you run that command.
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 use Laravel 5.2 and I created database tables by running
php artisan make:migration create_categories_table --create=categories
and
php artisan make:migration create_posts_table --create=posts
and then I run php artisan migrate, and tables are created in database. But after I made some changes in migration file "create_posts_table.php" and run
php artisan migrate:rollback
I got an error:
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'CreatePostsTable' not found
PHP Fatal error: Class 'CreatePostsTable' not found in E:\programfiles\xampp\htdocs\deneme\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php on line 336
my create_posts_table.php is
I tried composer update, composer dump-autoload but that hasn't fixed the problem.
I was getting the same problem. May this helps somebody: run composer dump-autoload before running migrate:rollback.
Before you run a migration, you should run the following commands to make sure cache has been cleared:
php artisan clear-compiled
php artisan optimize
This will make sure your new migration class has been registered correctly.
I've run artisan migrate:reset.
I've deleted some of my migration files because I didn't need these tables anymore.
I ran composer dump-autoload followed by artisan dump-autoload
I ran artisan migrate and I keep getting this error:
PHP Fatal error: Class 'Foo' not found in /vagrant/LaravelBackend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php on line 297
I tried to:
Run again composer dump-autoload and artisan dump-autoload (also used artisan clear-compiled)
Remove the migration table and run artisan migrate:install
Remove the vendor and composer.lock file and run composer install
Search within my project with PHPStorm for class Foo. Didn't find anything.
I keep getting the same error. It's the first time I run this since I updated to 4.2 if that could be related. Anything else I should be looking for?
I had this problem too.
Must remember: class name must be in accordance with filename.
Simple file renaming helped me:)
For example: in file "2014_12_08_100923_create_items_tables.php" must be class with name "CreateItemsTables" with using CamelCase words.
I solved my problem by
Removing all migration
Running composer dump-autoload
Adding them back one by one and running php artisan migrate
Deleting those that caused Laravel to throw an error
Create new migrations to replace the deleted ones
I'm not sure why that worked but my guess is that I might have modified the class name of these problematic migrations in the past.
I also found that renaming the migration with its initial name (The one throwed with the fatal error) also works for some of them.
I ran into this aswell and the solution was different to all of the above. The reason it was failing was because the filename was still mentioned in the migrations table of the DB. Because there were no unique columns I couldn't remove it with PHPMyAdmin and had to tak the CLI route.
Login to your server as root.
Type the following:
mysql -p database_name
(it now prompts for your password. From here on out everything is preceded with mysql > which just means that you're in the Mysql environment.
select * from migrations;
Look for the migration file you removed and copy the name.
delete from migrations where migration = '2015_07_21_000119_create_some_table';
It should mention something about 1 row affected. Now verify that it's gone by typing the first command again:
select * from migrations;
If it's gone exit the Mysql environment by typing
exit;
Now try 'php artisan migrate:rollback' again and it should work like a charm :-)
The actual solution is to use the correct naming for your translations. You still may need to do a
composer dump-autoload
The migration files must be as follows
YYYY_MM_DD_000000_create_some_table.php
and the class name inside must be
class CreateSomeTable extends Migration{}
There is an easier way.
Recreate those delete migrations manually. artisan make:migration
run artisan migrate:reset to rollback
Delete those dummy migations files just created.
run artisan migrate:refresh
I know this is a bit past but there is a better way actually. Run the following in terminal and feel free yourself to remove any of them:
~$ php artisan clear-compiled;php artisan cache:clear;php artisan config:clear;php artisan debugbar:clear;php artisan view:clear;php artisan optimize
To do it a regular task create an executable file named artisan-clear:
#!/bin/bash
php artisan clear-compiled
php artisan cache:clear
php artisan config:clear
php artisan debugbar:clear
php artisan view:clear
php artisan optimize
For me, the solution was that my class name inside the migration somehow started with a lowercase letter. When I changed the class name to be all upper case, then ran a composer dump-autoload, it ended up working for me. This is using Laravel 5.1, for what it's worth.
I did like this:
1. Deleted row non exist migration from migrations table from database
2. And run the command php artisan migrate:refresh
This helped to solve my problem.
*all your data will deleted from database tables
version 5.1.3 same problem fix it me:
drop database all tables
php artisan migrate:status
output: No migrations found.
ok use it
php artisan migrate:install
php artisan migrate
output is:
Migrated: 2016_11_24_093015_dt_some_table
Migrated: 2016_12_05_141004_dt_some_table
Migrated: 2016_12_07_110518_dt_some_table
Migrated: 2016_12_08_141807_dt_some_table
Migrated: 2016_12_13_090832_dt_some_table
this problem is solved
I had the same problem. When I was hiting php artisan migrate:reset, I got Class 'CreateImagesTable' not found. And composer dump-autoload didn't help.
My solution was very easy:
php artisan make:migration create_images_table --create=images
composer dump-autoload
Then I got:
SQLSTATE[HY000]: General error: 1 no such table: images (SQL: drop table "images")
so in sqlite I typed:
CREATE TABLE `images` (
...> `id` INTEGER
...> );
And then php artisan migrate:reset
Now I'm happy again
If artisan doesn't work at all and keeps throwing you this message no matter the command you give, delete the config.php file from bootstrap/cache folder.
After that run again
php artisan config:cache