cln/doc
Rusty Russell 3ae222540b plugins/sql: use created_index as primary key, where available.
It's a unique integer, and very useful for querying changes.  Unlike
our generated rowid, it's *stable* across queries.

We still need an explicit rowid column for list commands which don't
(currently) have this.

Here's the documentation diff:

    @@ -85,69 +85,69 @@
     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.
    +Note that tables which have a `created_index` field use that as the primary key (and `rowid` is an alias to this), otherwise an explicit `rowid` integer primary key is generated, whose value changes on each refresh.  This field 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).
     
     The following tables are currently supported:
     - `bkpr_accountevents` (see lightning-bkpr-listaccountevents(7))
    @@ -119,14 +119,14 @@
       - `payment_id` (type `hex`, sqltype `BLOB`)
     
     - `chainmoves` indexed by `account_id` (see lightning-listchainmoves(7))
    -  - `created_index` (type `u64`, sqltype `INTEGER`)
    +  - `created_index` (type `u64`, sqltype `INTEGER PRIMARY KEY`)
       - `account_id` (type `string`, sqltype `TEXT`)
       - `credit_msat` (type `msat`, sqltype `INTEGER`)
       - `debit_msat` (type `msat`, sqltype `INTEGER`)
       - `timestamp` (type `u64`, sqltype `INTEGER`)
       - `primary_tag` (type `string`, sqltype `TEXT`)
       - related table `chainmoves_extra_tags`
    -    - `row` (reference to `chainmoves.rowid`, sqltype `INTEGER`)
    +    - `row` (reference to `chainmoves.created_index`, sqltype `INTEGER`)
         - `arrindex` (index within array, sqltype `INTEGER`)
         - `extra_tags` (type `string`, sqltype `TEXT`)
       - `peer_id` (type `pubkey`, sqltype `BLOB`)
    @@ -139,7 +139,7 @@
       - `blockheight` (type `u32`, sqltype `INTEGER`)
     
     - `channelmoves` indexed by `account_id` (see lightning-listchannelmoves(7))
    -  - `created_index` (type `u64`, sqltype `INTEGER`)
    +  - `created_index` (type `u64`, sqltype `INTEGER PRIMARY KEY`)
       - `account_id` (type `string`, sqltype `TEXT`)
       - `credit_msat` (type `msat`, sqltype `INTEGER`)
       - `debit_msat` (type `msat`, sqltype `INTEGER`)
    @@ -204,7 +204,7 @@
       - `last_stable_connection` (type `u64`, sqltype `INTEGER`)
     
     - `forwards` indexed by `in_channel` and `in_htlc_id` (see lightning-listforwards(7))
    -  - `created_index` (type `u64`, sqltype `INTEGER`)
    +  - `created_index` (type `u64`, sqltype `INTEGER PRIMARY KEY`)
       - `in_channel` (type `short_channel_id`, sqltype `TEXT`)
       - `in_htlc_id` (type `u64`, sqltype `INTEGER`)
       - `in_msat` (type `msat`, sqltype `INTEGER`)
    @@ -222,7 +222,7 @@
     
     - `htlcs` indexed by `short_channel_id` and `id` (see lightning-listhtlcs(7))
       - `short_channel_id` (type `short_channel_id`, sqltype `TEXT`)
    -  - `created_index` (type `u64`, sqltype `INTEGER`)
    +  - `created_index` (type `u64`, sqltype `INTEGER PRIMARY KEY`)
       - `updated_index` (type `u64`, sqltype `INTEGER`)
       - `id` (type `u64`, sqltype `INTEGER`)
       - `expiry` (type `u32`, sqltype `INTEGER`)
    @@ -242,7 +242,7 @@
       - `bolt12` (type `string`, sqltype `TEXT`)
       - `local_offer_id` (type `hash`, sqltype `BLOB`)
       - `invreq_payer_note` (type `string`, sqltype `TEXT`)
    -  - `created_index` (type `u64`, sqltype `INTEGER`)
    +  - `created_index` (type `u64`, sqltype `INTEGER PRIMARY KEY`)
       - `updated_index` (type `u64`, sqltype `INTEGER`)
       - `pay_index` (type `u64`, sqltype `INTEGER`)
       - `amount_received_msat` (type `msat`, sqltype `INTEGER`)
    @@ -408,7 +408,7 @@
       - `features` (type `hex`, sqltype `BLOB`)
     
     - `sendpays` indexed by `payment_hash` (see lightning-listsendpays(7))
    -  - `created_index` (type `u64`, sqltype `INTEGER`)
    +  - `created_index` (type `u64`, sqltype `INTEGER PRIMARY KEY`)
       - `id` (type `u64`, sqltype `INTEGER`)
       - `groupid` (type `u64`, sqltype `INTEGER`)
       - `partid` (type `u64`, sqltype `INTEGER`)

Changelog-Changed: Plugins: `sql` tables `forwards`, `htlcs`, `invoices`, `sendpays` all use `created_index` as their primary key (and `rowid` is now an alias to this).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2025-08-19 13:37:50 +09:30
..
beginners-guide doc: Fix links to avoid 404 error 2025-06-26 14:21:56 +09:30
contribute-to-core-lightning chore: update docs for uv 2025-08-11 11:06:22 +09:30
developers-guide libplugin: correctly wrap notifications we send in the notification name. 2025-08-18 10:01:07 +09:30
getting-started doc: Add macOS uv instructions to installations.md 2025-08-18 14:20:12 +09:30
miscellaneous move old misc file to another folder 2023-07-16 12:59:40 +09:30
node-operators-guide doc: Fix links to avoid 404 error 2025-06-26 14:21:56 +09:30
schemas plugins/sql: use created_index as primary key, where available. 2025-08-19 13:37:50 +09:30
.gitignore doc: document the sql command. 2023-01-30 15:15:41 -06:00
CHANGELOG.md docs: Add configuration for the sphinx documentation generator 2019-02-18 02:42:29 +00:00
index.rst lightningd: add listchainmoves and listchannelmoves commands. 2025-08-19 13:37:50 +09:30
LICENSE.md docs: Add LICENSE to the About section 2023-03-25 15:40:35 +10:30
lightning-cli.1.md chore: fix some minor issues 2025-08-15 11:05:51 +09:30
lightning-hsmtool.8.md hsmtool: implement new "derivetoremote" method 2025-07-08 12:21:24 +09:30
lightning-reckless.1.md reckless: add update command 2025-05-14 13:02:03 +09:30
lightningd-config.5.md wss-proxy: replaced by a rust version 2025-07-24 12:42:06 -07:00
lightningd-rpc.7.md doc: fix typo and missing ws: prefix documentation. 2025-07-23 13:52:25 -07:00
lightningd.8.md newaddr: various fixes for msggen and docs 2024-04-17 14:47:52 +02:00
Makefile lightningd: add listchainmoves and listchannelmoves commands. 2025-08-19 13:37:50 +09:30
reckless.7.md Separate reckless utility (1) and reckless rpc (7) documentation 2025-05-13 19:11:27 +09:30
rpc-schema-draft.json doc: fix all JSON schemas to enforce no additional properties. 2024-10-30 15:39:12 +10:30
undoc-flags.list tools/check-manpage.sh: update undoc to a simple list. 2023-08-18 20:29:34 +09:30