plugins/sql: fix foreign keys.

I noticed that our subtables were not being cleaned, despite being "ON
DELETE CASCADE".  This is because foreign keys were not enabled, but
then I got foreign key errors: rowid cannot be a foreign key anyway!

So create a real "rowid" column.  We want "ON DELETE CASCADE" for
nodes and channels (and other tables in future) where we update
partially.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2023-02-01 12:28:32 +10:30
committed by Alex Myers
parent 3dde1ca399
commit f87c7ed439
3 changed files with 41 additions and 16 deletions

View File

@@ -80,6 +80,12 @@ Additionally, only the following functions are allowed:
TABLES
------
Note that the first column of every table is a unique integer called
`rowid`: this is used for related tables to refer to specific rows in
their parent. sqlite3 usually has this as an implicit column, but we
make it explicit as the implicit version is not allowed to be used as
a foreign key.
[comment]: # (GENERATE-DOC-START)
The following tables are currently supported:
- `bkpr_accountevents` (see lightning-bkpr-listaccountevents(7))