admin管理员组文章数量:1402857
I have a SQLite database in ./database/database-file.sqlite
.
In Laravel, the database is so configured:
// ./config/database.php
return [
...
'connections' => [
'my-custom-connection' => [
'driver' => 'sqlite',
'database' => database_path('database-file.sqlite'),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
...
When I run the app locally, in Docker, all works as expected and database_path()
correctly returns the right path to the SQLite file.
However, when I run the app on Heroku, the resulting error is this:
Database file at path [/tmp/build_1032c5ba/database/database-file.sqlite] does not exist. Ensure this is an absolute path to the database.
The problem is that, on Heroku, the base path is identified as /tmp/build_*
instead of /app/database/
.
Missing storage
folder
Different problem, same (?) root cause:
file_put_contents(/tmp/build_1032c5ba/storage/framework/sessions/0OoO2UaEvEqiVygomKADbevSLNSZ7ypiWg9KaLrT): Failed to open stream: No such file or directory
Apart the fact I'm using file sessions (I will change this later: I'm aware of the ephemeral nature of the Heroku's filesystem), the problem is the same: the folder is present and accessible, but, on Heroku, the base path is again /tmp/build_*
.
This is obviously wrong, as the correct base path should have been app/storage/...
.
What I checked
I logged in the dyno and checked the file /app/database/database-file.sqlite
actually exists in the folder.
I did the same for the storage
folder: it exists and can be accessed.
The problem seems to be the way the base path is identified.
Any ideas about the reason of this mismatching between local Docker and Heroku in identifying the base path?
本文标签:
版权声明:本文标题:Laravel on Heroku cannot find a SQLLite database stored in the project (nor the `storage` folder) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744365689a2602765.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论