I'm working through Laracasts Laravel 5 Fundamentals however when coming to run a migration again I found that I had duplicate migrations at which point I figured - I should likely delete that. So I did... then began my issues.
When I attempt to load a migration now I get the following error:
[ErrorException]
include(/home/vagrant/Code/Laravel/database/migrations/2015_05_24_211527_create_articles_table.php): failed to
open stream: No such file or directory
However when I checked my database (Note that I have deleted and recreated it in order to combat my issue) and there are only two records in the mirgations table:
vagrant#homestead:~/Code/Laravel$ sqlite3 storage/database.sqlite
SQLite version 3.8.6 2014-08-15 11:46:33
Enter ".help" for usage hints.
sqlite> select * from migrations;
2014_10_12_000000_create_users_table|1
2014_10_12_100000_create_password_resets_table|1
sqlite>
Any help would be appreciated, if I'm being a moron and missing something obvious please feel free to point that out too.
Thanks!
The first error:
[ErrorException]
include(/home/vagrant/Code/Laravel/database/migrations/2015_05_24_211527_create_articles_table.php): failed to
open stream: No such file or directory
should be fixed executing composer dump-autoload.
About the second one: "However when I checked my database (Note that I have deleted and recreated it in order to combat my issue) and there are only two records in the mirgations table:"
As you said that you have recreated it, something went wrong because there is no migrations table, delete it and build it again
rm storage/database.sqlite
touch storage/database.sqlite
php artisan migrate:install
php artisan migrate
Please try, this one helped me to solve my problem
composer dump-autoload
Thanks
Related
I have the project with symfony5 and doctrine orm. I created entity in my project. And now I want to delete the entity from model. I deleted relashionships this entity and made migration. Then i deleted this entities from the project and made migration. But when I try to create new entity in php bin/console, i get next error:
Warning: include(C:\OpenServer\elearning\vendor\composer/../../src/Entity/Theme.php): failed to open stream: No such file or directory
What am i doing wrong?
I tried to make php bin/console d:s:u --force, but the error still appears
A little bit late but i just had the same problem.
Try running composer dump-autoload to generate a new classmap. Your ...\Entity\Theme.php probably still exists there.
After that, you should be able to run console commands again.
I tried building a database where I forgot to place the index of the table. Now I'm trying to rollback the migration but its not working out. It is throwing some error
[ErrorException] Undefined index: 2017_01_06_195028_create_users_themes_table
Now I tried deleting it manually so I deleted the migration file from the database folder and then did composer dump-autoload, and then did rollback it is still showing same error. Also when this didn't happened I tried placing index in the table through phpmyAdmin, it ain't helped! Still i deleted the table manually and tried doing composer dump-autoload and rollback it still has same error.
Help me out with this.
You can backup DB data (if any), drop DB and create it again and run php artisan migrate command. It's the easiest way to fix this I guess.
Another thing you could try is to delete last batch from migrations table and drop tables from last batch and run php artisan migrate
When you do php artisan migrate, migration table is created and it records the order of the migration you run. And when you rollback the list get cleared in the order of rollbacks..
In your case since you got an error the record corresponding to your migration probably still in the migration table.
Now if you wish to update your migration file and migrate again, you needs to manually clear the corresponding record from the migration table. Most probably it would be the last record in the migration table.
Clear out that record, fix your migration file and run your migration. You should be good to go.
I forgot to mention that I'm having my migration files in different folder so everytime I'm doing a php artisan migrate rollback I need to specify the path of those migration file that is why it is showing undefined Index error.
I have created many tables use migration file, but I have dropped some table via the mysql command line tool, then I find the migration status about the tables I have dropped is still ran, so how can i fix it?
When I use migrate command, it always says nothing to migrate, but I have no table in my database.
I have tried to delete all the logs and stuff under the storage path.
I have also tried to delete the migration table on mysql or change .env file to use a new database, but both cannot work. Can anyone help me?
I use laravel 5.1.
`Run migrate:rollback (to undo the last migration)
If migrate:rollback doesn't work ; do it manually:
step 1 : delete the migration file
step 2 : composer dump-autoload (for resetting autoload file)
step 3 : remove the last entry from migration(to modify your database)`
The reason you are not able to migrate although you dont have existing tables in database is because your previous migrations still exist. Either clear the history or perform the above steps
To make a long story short, I have completely messed up my Laravel migrations on my local machine. They are 100% unusable.
I'm working with Laravel 5 for the first time, so I'm just messing with stuff and testing the waters, so to speak. Between manually tinkering with the database, rewriting my migrations, accidentally deleting a table or two (then the 'migrations' table itself [doh!]), I'm in this mixed-up state, and I just want to start all of the migration stuff over from scratch. However, I can't seem to figure out how to do that.
I'm currently stuck in a state where I can't do anything.
For example, if any remnants of old tables are still in the database when I perform php artisan migrate:refresh, I get a Base table or view already exists error message. However, if I delete all the tables, I get this error:
Next exception 'Illuminate\Database\QueryException' with message
'SQLSTATE[42S02]: Base table or view not found: 1146 Table
'bsd_status.projects' doesn't exist (SQL: select * from `projects`)' in
path/to/src/Illuminate/Database/Connection.php:620
I've run the following commands:
$ php artisan clear-compiled
$ php artisan cache:clear
$ php composer dump-autoload
$ php artisan migrate:install
I'm not even sure I'm doing this stuff in the right order. Anyway, other than completely reinstalling Laravel, how does one get all his/her migrations back to "out-of-the-box?" Any help would be greatly appreciated. Thanks!
What I liked to do is manually delete all the tables with what ever tool you use on your device. For me I just use phpmyadmin. After that I do.
php artisan migrate:install
php artisan migrate:refresh
Don't know if this is the official way, but it works every time.
If you don't want to use phpmyadmin you can just
login to mysql via command line
mysql -u root -p
DROP DATABASE laraveldb;
CREATE DATABASE laraveldb;
Although #Goddard's answer and #nozzleman's comment were both really helpful (I've used both suggestions several other times, so thank you), the solution had nothing to do with migrations. Well, … other than the fact that I screwed them up to begin with.
Anyway, nothing I did fixed the issue, so I put on my "think really f'ing hard" hat. After cursing for several minutes, I realized something. It appeared that — even when simply running artisan from the command line — any routes or providers I had set up were attempting to be "resolved" (or whatever the proper terminology is). Thus, I must have had a call somewhere attempting to get data from the missing table when the app started the bootstrap/init/start/run phase.
I decided to make sure I didn't have any weird things going on in my actual code, so I checked in my routes file (app/Http/routes.php) and all my Service Provider files (app/Providers/*) to see if I was trying to retrieve model data in any of them. Lo and behold, I opened app/Providers/AppServiceProvider.php and found this:
AppServiceProvider.php
public function boot()
{
$layout = 'default';
if ( Request::has('layout') ) {
$layout = Request::input('layout');
}
view()->share('sharedAppData', [
'layout' => $layout,
'projects' => App\Project::all() // <- WTF, mate?
]);
}
If you recall, the table being complained about in the error messages was named "projects." Thus, I was attempting to get all projects at boot, so no matter what I did (at the command line or otherwise), nothing was going to work because my Eloquent-extended model (App\Project) was looking for a table that simply didn't exist anymore.
The moral of the story: Laravel is super complex, I suck at it, and no matter how many times I try to follow the teachings of the great Jeffery Way, I'll forever be a Laran00b.
try this:
composer dump-autoload
composer clear-cache
im trying to install Sylius with composer for an e commerce project however i just cant get it done..i follow the docs but i always get an other error when i fix one.
already fixed some errors eg. incl extension exception, paypal bundle renaming issues on git and memory size problem.
Now where im stuck:
When i fill the parameters with the interactive script
if i give any password for the database i get this:
Doctrine\DBAL\Driver\PDOException
Acces denied for user 'root'#localhost
if i dont give password then i get this:
Doctrine\DBAL\Driver\PDOException
SQLSTATE[HY000]Unknown database databasename_dev (it appends _dev prefix)
then in both cases it ends up with this: RunTimeException
An error occured when executing the ""cache:clear --no-warmup"" command
and the proccess is terminated with this exception..
i tried if i could continue with the $ cd acme
$ php app/console sylius:install commands but:
if i gave a password then get acces denied Doctrine\DBAL\Exception\ConnectionException
if didnt then Doctrine\DBAL\Driver\PDOException
SQLSTATE[HY000]Unknown database databasename_dev
i created the database manually which seems to solve the problem however get this: General error: 1007 cant create database databasename_dev; database exists
(i dont think this solution is the right one)
but after this it doesnt terminate yet and creates the database schema and then after some installation it terminates with this:
RuntimeException
The source file "C:\Users\user\acme\app/../web/bundles/cmfcreate/vendor/create/themes/midgard-tags/tags.css" does not exists
i checked the page if it may useable but got twig exception that currency not found and many components are missing from the page..
What's your workspace?
If you work on Windows with WAMP I'll give you some things to check :
set the database port to : 3306
create a new user for the database, juste for your sylius project
when you run create-project commande, in databaseport write : localhost
I hope it helps you.