我可能在最后一个小时里一直在挠头,试图弄清楚发生了什么事。
我删除了我的database.sql 文件,因为我想要从头开始创建一个新文件。我已经这样做了几十次,但是在运行 php artisan
migrate:fresh
时,它返回了以下错误:
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
Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(App\Providers\AppServiceProvider))
+17 vendor frames
19 app/Providers/AppServiceProvider.php:24
Illuminate\Support\Facades\Facade::__callStatic("table")
这个一直都是自己创建数据库的,为什么现在不行了?
我在原始目录中手动创建了database.sqlite,结果却出现了这个错误:
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▕ }
我认为这可能是 create_kingdoms_table.php 迁移的问题,所以我将其删除以查看,不知何故,即使迁移消失,即使清除缓存后,错误仍然相同。
php artisan 配置:清除
php artisan 迁移:回滚 php artisan 迁移