You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行php artisan migrate时Sqlite报‘no such table: pragma_compile_options’错误求助

解决Laravel迁移时SQLite的pragma_compile_options错误

问题场景

我正在跟随Laravel bootcamp教程学习,安装Laravel后将DB_CONNECTION改为sqlite,运行php artisan migrate完成Laravel Breeze安装时抛出SQLite异常,错误输出如下:

$ php artisan migrate

   Illuminate\Database\QueryException

  SQLSTATE[HY000]: General error: 1 no such table: pragma_compile_options (Connection: sqlite, SQL: select exists (select 1 from pragma_compile_options where compile_options = 'ENABLE_DBSTAT_VTAB') as enabled)

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:822
    818▕                     $this->getName(), $query, $this->prepareBindings($bindings), $e
    819▕                 );
    820▕             }
    821▕
  ➜ 822▕             throw new QueryException(
    823▕                 $this->getName(), $query, $this->prepareBindings($bindings), $e
    824▕             );
    825▕         }
    826▕     }

      +30 vendor frames

  31  artisan:35
      Illuminate\Foundation\Console\Kernel::handle()

已创建空的database/database.sqlite文件,当前SQLite版本为3.32.3,Laravel版本为10.34.2。

解决方案

  • 升级SQLite版本:Laravel 10要求SQLite版本至少为3.37.0,你的3.32.3版本过低,pragma_compile_options作为表查询的支持在3.37.0版本才正式引入。直接将SQLite升级到最新稳定版即可解决该错误。
  • 确认数据库配置路径:检查.env文件中DB_DATABASE的配置,确保指向正确的文件路径,比如使用绝对路径DB_DATABASE=/absolute/path/to/database/database.sqlite,避免相对路径导致的文件识别问题。
  • 临时绕过检查(不推荐):如果暂时无法升级SQLite,可以修改Laravel的SQLite连接逻辑:找到vendor/laravel/framework/src/Illuminate/Database/SQLiteConnection.php文件,注释掉检查ENABLE_DBSTAT_VTAB的相关代码段。注意此修改会被后续框架更新覆盖,仅作为临时应急方案。

内容的提问来源于stack exchange,提问作者Jonathan Montgomery

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 12:12:35