Skip to content

Conversation

@nunomaduro
Copy link
Member

In Laravel 11, the database driver is the default store for the cache. Sometimes, if the user chooses SQLite as the database driver, SQLite will be used for caching. Typically, when the user creates a fresh Laravel application, the database/database.sqlite file may not exist, which can cause issues when starting a fresh Laravel application (via laravel new) or even just executing php artisan in the console:

   Illuminate\Database\QueryException

  Database file at path [/Users/nunomaduro/Work/Code/laravel/database/database.sqlite] does not exist. Ensure this is an absolute path to the database. (Connection: sqlite, SQL: PRAGMA foreign_keys = ON;)

This pull request addresses the issue by effectively ignoring the error in the constructor. While this approach may seem simplistic, it is the safest solution for two reasons:

  1. Users who directly access the PDO will still have the query (update) executed, ensuring no change in behavior.
  2. Users who later access the database, such as through the cache (for example, using cache::get), will still encounter the "Database does not exist" error.

@nunomaduro nunomaduro marked this pull request as ready for review January 11, 2024 14:46
@nunomaduro nunomaduro changed the title [11.x] Fixes SQLiteConnection::__construct throwing exceptions [11.x] Avoids SQLiteConnection::__construct throwing exceptions Jan 11, 2024
@taylorotwell taylorotwell merged commit 0026a0a into master Jan 11, 2024
@taylorotwell taylorotwell deleted the fix/sqlite-connection-constructor-error branch January 11, 2024 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants