I’ve been scratching my head for maybe the last hour trying to figure out what’s going on.
I deleted my database.sql file since I wanted a new one from scratch. I’ve done this dozens of times, but upon running php artisan migrate:fresh
it returned the following error:
Database file at path [{..}/database/database.sqlite] does not exist. Ensure this is an absolute path to the database. (Connection: sqlite, SQL: PRAGMA foreign_keys = ON;)
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:829
825▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
826▕ );
827▕ }
828▕
➜ 829▕ throw new QueryException(
830▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
831▕ );
832▕ }
833▕ }
1 [internal]:0
IlluminateFoundationApplication::IlluminateFoundation{closure}(Object(AppProvidersAppServiceProvider))
+17 vendor frames
19 app/Providers/AppServiceProvider.php:24
IlluminateSupportFacadesFacade::__callStatic("table")
This has always created the database itself, why is it not now?
I created the database.sqlite in the original directory manually, and it came out with this error instead:
SQLSTATE[HY000]: General error: 1 no such table: kingdoms (Connection: sqlite, SQL: select count(*) as aggregate from "kingdoms")
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:829
825▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
826▕ );
827▕ }
828▕
➜ 829▕ throw new QueryException(
830▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
831▕ );
832▕ }
833▕ }
I thought this might be an issue with the create_kingdoms_table.php migration, so I removed it to see, and somehow, the error is still the same even with the migration gone, even after clearing cache.
2
Answers
php artisan config:clear
php artisan migrate:rollback
php artisan migrate
It might be possible that, in case of sqlite, it will do the migrate:fresh command only if the database exists because it has to drop tables and make new ones instead. Since you deleted the .sqlite file, it wasn’t able to migrate:fresh – but
might help in that case where you deleted the file, just don’t type in fresh.
In the second try, it wasn’t able to select count(*) while doing the migration?
I know i wrote this as an answer, but it’s too long for a comment. Will edit upon further investigation.