メインコンテンツへスキップ
FIM One supports two database backends: SQLite (default, zero-config) and PostgreSQL (recommended for production). The backend is determined by the 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

ローカル開発: SQLiteはそのまま動作します — データベースサーバーなし、Redisなし、設定は不要です。コーディングを開始するだけです。本番環境: Docker Composeでデプロイし、PostgreSQL + Redisが自動的にプロビジョニングされます。手動でのデータベースセットアップは不要です。

Known Limitation: SQLite Concurrent Streaming

SQLite can become a bottleneck under concurrent load.FIM One uses Server-Sent Events (SSE) for streaming AI responses. During streaming, each active SSE connection holds a database connection from the pool for the duration of the stream. SQLite enforces a global write lock, meaning only one write operation can proceed at a time — all other writes queue behind it.Even though the connection pool supports up to 15 simultaneous connections (pool_size=10 + max_overflow=5), the bottleneck is the lock itself, not the pool. When multiple users are chatting simultaneously, their write operations (saving messages, updating token counts) serialize against each other.Symptoms you may observe:
  • Conversation list loads slowly while another user is streaming
  • Settings pages feel sluggish during active chat sessions
  • API responses are delayed when multiple streams are active
Recommendation: If you have more than 2-3 concurrent users, switch to PostgreSQL. PostgreSQL uses MVCC (Multi-Version Concurrency Control) with row-level locking, so concurrent reads and writes proceed independently without blocking each other.

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 with SQLITE_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 に既存の会話、エージェント、またはコネクタがあり、それらを保持する必要がある場合は、以下のデータマイグレーションセクションを参照してください。
If you deploy with Docker Compose, PostgreSQL and Redis are already included and auto-configured — there is nothing extra to set up. The docker-compose.yml sets DATABASE_URL internally — your .env value is overridden:
No additional database setup is needed when using Docker Compose.

データ移行

SQLiteからPostgreSQLへの組み込み移行ツールはありません。ほとんどのデプロイメントでは、推奨されるアプローチはあなたの状況によって異なります: 新規デプロイメント(既存データなし): DATABASE_URLをPostgreSQLの接続文字列に設定し、FIM Oneを起動するだけです。すべてのテーブルは自動的に作成されます。 保持する必要がある既存データ: 手動エクスポート/インポートが必要です。一般的なアプローチ:
  1. sqlite3 CLIやPythonスクリプトなどのツールを使用してSQLiteからデータをエクスポートする
  2. 必要に応じてデータを変換する(SQLiteとPostgreSQLにはマイナーな型の違いがあります)
  3. psql、pg_restore、またはアプリケーションレベルの挿入スクリプトを使用してPostgreSQLにインポートする
開発セットアップから本番環境にアップグレードするほとんどのユーザーにとって、PostgreSQLで新規に開始し、UIを通じてエージェントとコネクタを再作成する方が簡単です。会話履歴は通常、手動移行を正当化するほど重要ではありません。