DATABASE_URL environment variable.
start.sh and the Docker entrypoint run the Alembic migrations on every start, so tables are created automatically — no manual migration step is required.
SQLite vs PostgreSQL
Known Limitation: SQLite Concurrent Streaming
Connection Pool Configuration
FIM One configures SQLAlchemy connection pool settings internally for each backend. These are tuned defaults that do not require environment variables (the SQLite pool can be resized withSQLITE_POOL_SIZE / SQLITE_MAX_OVERFLOW) — they are applied automatically based on the DATABASE_URL scheme. Understanding them helps explain runtime behavior.
SQLite Pool Settings
WAL mode and the 30-second busy timeout are set via SQLite PRAGMAs on every new connection. This combination ensures that short-lived reads (loading a conversation list, fetching settings) are not blocked by long-running write transactions, and that concurrent writes queue gracefully instead of failing.
PostgreSQL 连接池设置
PostgreSQL 通过 MVCC 原生处理并发,因此连接池设置主要控制资源使用而非竞争。30 分钟的回收间隔可以避免防火墙、负载均衡器或托管数据库服务无声地丢弃空闲 TCP 连接的问题。
切换到 PostgreSQL
第 1 步:启动 PostgreSQL 实例
最快的方式是使用 Docker:第 2 步:设置 DATABASE_URL
在你的.env 文件中添加或更新以下行:
第 3 步:重启 FIM One
现有 SQLite 数据不会自动迁移。 将
DATABASE_URL 从 SQLite 切换到 PostgreSQL 会使用全新数据库启动。如果您在 SQLite 中有需要保留的现有对话、智能体或连接器,请参阅下面的数据迁移部分。Docker Compose (Recommended for Production)
If you deploy with Docker Compose, PostgreSQL and Redis are already included and auto-configured — there is nothing extra to set up. Thedocker-compose.yml sets DATABASE_URL internally — your .env value is overridden:
数据迁移
SQLite 到 PostgreSQL 没有内置的迁移工具。对于大多数部署,推荐的方法取决于您的情况: 全新部署(无现有数据): 只需将DATABASE_URL 设置为您的 PostgreSQL 连接字符串并启动 FIM One。所有表都会自动创建。
必须保留现有数据: 需要手动导出/导入。一般方法:
- 使用
sqlite3CLI 或 Python 脚本等工具从 SQLite 导出数据 - 根据需要转换数据(SQLite 和 PostgreSQL 有细微的类型差异)
- 使用
psql、pg_restore或应用级别的插入脚本导入到 PostgreSQL