Skip to content

[FEATURE]: Support more DBMS' for OpenCode state storage #14212

Closed as not planned

Description

@matthewijordan

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Migration to Drizzle for session storage/state has opened the door to enabling support for other DBMS' (e.g. postgres).

We run opencode on temporary infrastructure, this would enable our opencode data to be easily queried when offline or when migrating between hosts.

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Feb 19, 2026
  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Feb 19, 2026
  3. github-actions commented on Feb 19, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  4. miararoy commented on Mar 9, 2026

    @miararoy

    +1 on this, any thoughts from OC team?

  5. arthur-flam commented on Mar 11, 2026

    @arthur-flam

    Hi! It is also very useful on HPC environments (Slurm , LFS..) where HOME is on shared storage and users run opencode from multiple servers. We've run into corrupted database as file locks aren't reliable enough on NFS. The cleanest approach seems to use a remote database like postgresql. While theoretically drizzle makes it simple, there is a cost for maintainers if they plan on relying more into the sqlite ecosystem.

  6. skymoore commented on Apr 2, 2026

    @skymoore

    Please do this one guys!

  7. drkaangunduz commented on Apr 7, 2026

    @drkaangunduz

    sqlite has issues, postgres support would be very nice

  8. mingfang commented on Apr 21, 2026

    @mingfang

    Can replace SQLite with pg0
    https://github.com/vectorize-io/pg0

  9. assigned and unassigned on Apr 26, 2026
  10. removed
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  11. emretinaztepe commented on May 10, 2026

    @emretinaztepe

    We can't persist sessions inside sandboxes due to not having remote db support. This leaves FUSE or rclone as the only few options for db persistence inside sandboxes such as Daytona or Cloudflare Sandbox, but both FUSE and rclone are not suitable for binary content such as sqlite.

    Support for custom databases would be great such as Cloudflare Durable Objects.

  12. smacz42 commented on May 17, 2026

    @smacz42

    Yeah, here I'm just looking to get it set up in my homelab for the family to use as a replacement for proprietary options, and the web interface is great, but for sure not being able to have a database contain the state breaks the traditional app structure, where state is best kept in flat files (that distributed filesystems are suited to manage) or in databases. I would love to see this in order to enable more stable deployments of this wonderful app.

  13. tripersonale commented on Jun 22, 2026

    @tripersonale

    Hey, we built a working PostgreSQL backend and wanted to share in case it helps move this forward.

    Approach:

    • Effect-native stack (@effect/sql-pg), same layer model as the SQLite path
    • Thin compat layer adds .get()/.all()/.run() to the PG query builder — zero changes needed in calling code
    • BIGINT normalization for timestamp fields that PG returns as strings
    • Config via OPENCODE_DATABASE_DIALECT=postgres + OPENCODE_DATABASE_URL

    Test suite:

    • SQLite: 977 pass / 57 fail / 3 skip
    • PostgreSQL: 977 pass / 57 fail / 3 skip (identical)
    • Baseline upstream/dev: 972 pass / 63 fail (net: +5 pass)

    Code: tripersonale/opencode branch feat/postgresql-backend (4 commits, no unrelated changes)

    Happy to open a focused PR if this aligns with your roadmap. If you are already working on this, no worries — the fork works for us either way.

  14. tripersonale commented on Jun 23, 2026

    @tripersonale

    Update (Jun 23, 2026): we forked properly and the feature branch is now at https://github.com/tripersonale/opencode/tree/feat/multi-database-backend

    Changes: 18 commits, 33 files, +1621/-326 vs upstream dev:

    • PostgreSQL adapter via @effect/sql-pg
    • Dialect-aware SQLite/PostgreSQL switching (OPENCODE_DATABASE_DIALECT env)
    • Atomic event sequence generation for concurrent PG writers
    • BIGINT normalization, credential lookup extensions
    • Test suite: 1035 pass / 3 skip / 0 fail on both dialects

    Tested on PostgreSQL 18.4 with concurrent writer workloads. Upstream PR coming when the diff stabilizes.

  15. smacz42 commented on Jun 23, 2026

    @smacz42

    Looking forward to the PR - would love to see that land in upstream!

  16. ainexxo-master commented on Jul 2, 2026

    @ainexxo-master
    • 1 on this
  17. jakiechris commented on Jul 27, 2026

    @jakiechris

    +1

  18. AlexMKX commented on Aug 13, 2026

    @AlexMKX

    I'd suggest check duckdb - it multithreaded and much faster than sqlite

  19. github-actions commented on Oct 13, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  20. smacz42 commented on Oct 15, 2026

    @smacz42

    bummer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions