-
Notifications
You must be signed in to change notification settings - Fork 17
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.