tursodatabase / turso-cli

Command line interface to Turso.
https://turso.tech
MIT License
211 stars 33 forks source link

`turso dev --db-file` needs to better handle the case where the sqlite db file is not suitable for use in sqld #582

Open CodingDoug opened 1 year ago

CodingDoug commented 1 year ago

Database files created by sqlite3 default to DELETE journal mode

# Create db file
$ sqlite3 test.db

But sqld requires them to be in WAL journal mode. This error surfaces if it is not:

# Try to get sqld to use the file directly
$ turso dev --db-file test.db
...
Error: failed to checkpoint database while recovering replication log

See: https://www.sqlite.org/wal.html#activating_and_configuring_wal_mode

A workaround here is obviously for the user of the CLI to run PRAGMA journal_mode=WAL; prior to using the file with the Turso CLI (and sqld).

On sqld: https://github.com/libsql/sqld/issues/558

cc @gamebox

gamebox commented 1 year ago

Lovely. I didn't even think about journal mode