lightninglabs / lightninglabs/lndinit
`migrate-db`: gracefully handle the case where no bbolt DB exists
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 37
- Forks
- 18
- Avg merge
- 1h 30m
- Merged PRs (30d)
- 1
Description
Right now lndinit migrate-db is smart enough to check and see if a migration from bbolt to SQL was already successfully complete and exit without error as long as -e, --error-on-existing is not passed.
However, if no bbolt DB exists, we get an error.
$ ./lndinit migrate-db -n regtest --dest.backend=sqlite
2026-01-27 23:19:28.962 [INF]: LNDINIT Version 0.1.33-beta commit=v0.1.33-beta, debuglevel=
2026-01-27 23:19:28.962 [INF]: LNDINIT Checking db version of database channeldb
2026-01-27 23:19:28.962 [INF]: LNDINIT Opening bolt backend at /home/zziigg/.lnd/data/graph/regtest/channel.db for prefix 'channeldb'
2026-01-27 23:19:28.962 [ERR]: LNDINIT Runtime error: failed to open source db with prefix `channeldb` for version check: database does not exist
I think we should handle this gracefully and add the option
--error-if-no-bbolt-db-exists (default: false)
because if no bbolt DB exists, LND should create a new SQLite DB automatically.
In addition, I think we should also consider adding the ability to create an empty bbolt DB and put a tombstone record in it if no bbolt DB exists.
--tombstone-empty-db-if-no-bbolt-db-exists (default: false)
that way when lndinit migrate-db goes to try and read a bbolt DB, it will think the conversion completed successfully and return a success as was mentioned above at the beginning of this issue. I'm not sure all the reasons people might want this. Maybe they won't and we should just skip this option, but I thought I would bring it up in case people don't like the other option I've proposed above.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the lndinit migrate-db command and follow the existing bbolt source-database version check and --error-on-existing handling. Determine how an absent bbolt database should affect SQLite creation and the proposed error or tombstone flags; done means the selected behavior is implemented and covered by migration tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sqlite
- Domain
- cli, databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100