考虑
laravel new bug
Run Code Online (Sandbox Code Playgroud)
然后加入.env
DB_CONNECTION=sqlite
DB_DATABASE=/home/me/Code/bug/storage/database.sqlite
Run Code Online (Sandbox Code Playgroud)
创建数据库
touch /home/me/Code/bug/storage/database.sqlite
Run Code Online (Sandbox Code Playgroud)
迁移
php artisan migrate && php artisan migrate:fresh
Run Code Online (Sandbox Code Playgroud)
现在尝试以修补程序的方式进行迁移
php artisan tinker
>> Artisan::call('migrate');
Run Code Online (Sandbox Code Playgroud)
第一次导致=> 0(如预期的那样?)但是第二次:
>>> Artisan::call('migrate:fresh')
Run Code Online (Sandbox Code Playgroud)
使用消息'SQLSTATE [HY000]照亮\ Database\QueryException:一般错误:17数据库模式已更改(SQL:select*from sqlite_master其中type ='table'和name = migrations)'
Artisan :: call('migrate')第三次:
Symfony\Component\Console\Exception\CommandNotFoundException,消息'在"migrate"命名空间中没有定义命令.
有什么想法在这里发生?你可以重现吗?
Symfony\Component\Console\Exception\CommandNotFoundException,消息'在"migrate"命名空间中没有定义命令.
更新2:此处提交的问题:https
://github.com/laravel/framework/issues/22997 https://github.com/laravel/tinker/issues/37
我不认为这是一个 Laravel 错误,但我发现了你的问题:
调用不存在的命令Artisan::call('migrate:fresh')
会崩溃。原因是一个拼写错误:tinker 不接受fresh
,只接受refresh
。通过tinker 调用命令将清空sqllite 文件,因此在不使用tinker 进行迁移之前您无法执行任何命令。
这是我的步骤:
php artisan migrate # sqllite file is filled with content
php artisan tinker
> Artisan:call('refresh')
> Artisan::call('fresh') # now the sqllite file is empty
> Artisan::call('migrate') # will crash
php artisan migrate
> Artisan::('refresh') # works
Run Code Online (Sandbox Code Playgroud)
所以我认为这是一个修补程序错误,而不是 Laravel 错误。Tinker 正在做某种快照(如果您更改模型,则必须重新启动 Tinker 才能在那里调用它),也许错误处理未实现是捕获所有错误的最佳方法。
归档时间: |
|
查看次数: |
529 次 |
最近记录: |