runes: Use next id from runes table not runes_uniqueid
from vars
#6715
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changelog-Fixed: runes: use runes table
id
insteadrunes_uniqueid
fromvars
because it returns incorrect unique id if rune/s migrated from datastore.Issue (#6696):
The issue occurs when user saves the rune (created by commando-rune) in the datastore with v23.02 and then upgrades the DB with v23.08. This upgrade calls migrate_datastore_commando_runes function to migrate runes from datastore to runes table. But it does not increment runes_uniqueid of vars table. So when user creates a new rune, CLN gets old next_unique_id and fails with UNIQUE_ID constraint error.
This issue effects Umbrel's users and users who saved their runes from older version in the datastore.
Solution 1:
runes_uniqueid
and update vars table.runes_uniqueid
in vars table inmigrate_datastore_commando_runes
for users who are yet to update.Solution 2:
runes_uniqueid
, instead calculate thenext_unique_id
fromrunes
table.id
can be auto generated for runes insert but we still need to maintain it in runes because:- It is also required by
rune_derive_start
- counter starts from 1 (not 0) if not explicitly passed to the query.
Implemented solution 2 as it is clean and future proof.