Skip to content

[sqlite] duplicate column name: cost migration error when upgrading from v1.14.41 to v1.17.11 #34584

Closed as not planned

Description

@Mr-j-yangyu

Description

I upgraded OpenCode from v1.14.41 to v1.17.11. Upon starting the container (using opencode serve --port 4096 --hostname 0.0.0.0), the application crashes during startup with the following error:

2026-06-30T13:35:31.315099944+08:00 Error: Unexpected error  
2026-06-30T13:35:31.315224249+08:00
2026-06-30T13:35:31.315250727+08:00 duplicate column name: cost

The service is running in a Docker container, with the entrypoint:

ENTRYPOINT ["/usr/bin/tini", "--"] 
CMD ["opencode", "serve", "--port", "4096", "--hostname", "0.0.0.0"]

Plugins

No response

OpenCode version

v1.14.41

Steps to reproduce

To Reproduce

  1. Previously had OpenCode v1.14.41 running with persisted data (likely in a mounted volume, e.g., ~/.local/share/opencode).
  2. Upgraded the container image to v1.17.11.
  3. Restarted the container with the same persistent data volume.
  4. The startup process attempts to perform a schema migration and fails with duplicate column name: cost.

Expected behavior

The migration should handle existing columns gracefully (e.g., check if column exists before adding) and complete successfully, preserving all historical data. The server should start normally.

Actual behavior

The migration fails, and the server exits with an error, preventing startup.

Possible Cause

The migration script tries to ALTER TABLE ADD COLUMN cost on a table that already contains a cost column. This can happen if:

  • The database schema from v1.14.41 already had a cost column, but the migration logic in v1.17.11 does not check for its existence before adding.
  • The migration is re‑executed on an already partially migrated database.

Workaround Attempted

I temporarily resolved this by deleting the database files (~/.local/share/opencode/opencode.db*) and letting the server recreate them, but this loses all historical session data. I would prefer a solution that preserves my data.

Environment

  • Deployment: Docker container
  • OpenCode Version (upgraded): v1.17.11
  • OpenCode Version (previous): v1.14.41
  • Persistent data path: /root/.local/share/opencode/ (or custom mount) – the database is SQLite.
  • Start command: opencode serve --port 4096 --hostname 0.0.0.0

Additional Context

  • The cost column appears to be related to session cost tracking.
  • I can provide more logs or test a patch if needed.

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. github-actions commented on Aug 30, 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.

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