-
Notifications
You must be signed in to change notification settings - Fork 913
/
db_postgres_sqlgen.c
1927 lines (1919 loc) · 101 KB
/
db_postgres_sqlgen.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifndef LIGHTNINGD_WALLET_GEN_DB_POSTGRES
#define LIGHTNINGD_WALLET_GEN_DB_POSTGRES
#include <config.h>
#include <wallet/db_common.h>
#if HAVE_POSTGRES
struct db_query db_postgres_queries[] = {
{
.name = "CREATE TABLE version (version INTEGER)",
.query = "CREATE TABLE version (version INTEGER)",
.placeholders = 0,
.readonly = false,
},
{
.name = "INSERT INTO version VALUES (1)",
.query = "INSERT INTO version VALUES (1)",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE outputs ( prev_out_tx BLOB, prev_out_index INTEGER, value BIGINT, type INTEGER, status INTEGER, keyindex INTEGER, PRIMARY KEY (prev_out_tx, prev_out_index));",
.query = "CREATE TABLE outputs ( prev_out_tx BYTEA, prev_out_index INTEGER, value BIGINT, type INTEGER, status INTEGER, keyindex INTEGER, PRIMARY KEY (prev_out_tx, prev_out_index));",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE vars ( name VARCHAR(32), val VARCHAR(255), PRIMARY KEY (name));",
.query = "CREATE TABLE vars ( name VARCHAR(32), val VARCHAR(255), PRIMARY KEY (name));",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE shachains ( id BIGSERIAL, min_index BIGINT, num_valid BIGINT, PRIMARY KEY (id));",
.query = "CREATE TABLE shachains ( id BIGSERIAL, min_index BIGINT, num_valid BIGINT, PRIMARY KEY (id));",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE shachain_known ( shachain_id BIGINT REFERENCES shachains(id) ON DELETE CASCADE, pos INTEGER, idx BIGINT, hash BLOB, PRIMARY KEY (shachain_id, pos));",
.query = "CREATE TABLE shachain_known ( shachain_id BIGINT REFERENCES shachains(id) ON DELETE CASCADE, pos INTEGER, idx BIGINT, hash BYTEA, PRIMARY KEY (shachain_id, pos));",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE peers ( id BIGSERIAL, node_id BLOB UNIQUE, address TEXT, PRIMARY KEY (id));",
.query = "CREATE TABLE peers ( id BIGSERIAL, node_id BYTEA UNIQUE, address TEXT, PRIMARY KEY (id));",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE channels ( id BIGSERIAL, peer_id BIGINT REFERENCES peers(id) ON DELETE CASCADE, short_channel_id TEXT, channel_config_local BIGINT, channel_config_remote BIGINT, state INTEGER, funder INTEGER, channel_flags INTEGER, minimum_depth INTEGER, next_index_local BIGINT, next_index_remote BIGINT, next_htlc_id BIGINT, funding_tx_id BLOB, funding_tx_outnum INTEGER, funding_satoshi BIGINT, funding_locked_remote INTEGER, push_msatoshi BIGINT, msatoshi_local BIGINT, fundingkey_remote BLOB, revocation_basepoint_remote BLOB, payment_basepoint_remote BLOB, htlc_basepoint_remote BLOB, delayed_payment_basepoint_remote BLOB, per_commit_remote BLOB, old_per_commit_remote BLOB, local_feerate_per_kw INTEGER, remote_feerate_per_kw INTEGER, shachain_remote_id BIGINT, shutdown_scriptpubkey_remote BLOB, shutdown_keyidx_local BIGINT, last_sent_commit_state BIGINT, last_sent_commit_id INTEGER, last_tx BLOB, last_sig BLOB, closing_fee_received INTEGER, closing_sig_received BLOB, PRIMARY KEY (id));",
.query = "CREATE TABLE channels ( id BIGSERIAL, peer_id BIGINT REFERENCES peers(id) ON DELETE CASCADE, short_channel_id TEXT, channel_config_local BIGINT, channel_config_remote BIGINT, state INTEGER, funder INTEGER, channel_flags INTEGER, minimum_depth INTEGER, next_index_local BIGINT, next_index_remote BIGINT, next_htlc_id BIGINT, funding_tx_id BYTEA, funding_tx_outnum INTEGER, funding_satoshi BIGINT, funding_locked_remote INTEGER, push_msatoshi BIGINT, msatoshi_local BIGINT, fundingkey_remote BYTEA, revocation_basepoint_remote BYTEA, payment_basepoint_remote BYTEA, htlc_basepoint_remote BYTEA, delayed_payment_basepoint_remote BYTEA, per_commit_remote BYTEA, old_per_commit_remote BYTEA, local_feerate_per_kw INTEGER, remote_feerate_per_kw INTEGER, shachain_remote_id BIGINT, shutdown_scriptpubkey_remote BYTEA, shutdown_keyidx_local BIGINT, last_sent_commit_state BIGINT, last_sent_commit_id INTEGER, last_tx BYTEA, last_sig BYTEA, closing_fee_received INTEGER, closing_sig_received BYTEA, PRIMARY KEY (id));",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE channel_configs ( id BIGSERIAL, dust_limit_satoshis BIGINT, max_htlc_value_in_flight_msat BIGINT, channel_reserve_satoshis BIGINT, htlc_minimum_msat BIGINT, to_self_delay INTEGER, max_accepted_htlcs INTEGER, PRIMARY KEY (id));",
.query = "CREATE TABLE channel_configs ( id BIGSERIAL, dust_limit_satoshis BIGINT, max_htlc_value_in_flight_msat BIGINT, channel_reserve_satoshis BIGINT, htlc_minimum_msat BIGINT, to_self_delay INTEGER, max_accepted_htlcs INTEGER, PRIMARY KEY (id));",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE channel_htlcs ( id BIGSERIAL, channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, channel_htlc_id BIGINT, direction INTEGER, origin_htlc BIGINT, msatoshi BIGINT, cltv_expiry INTEGER, payment_hash BLOB, payment_key BLOB, routing_onion BLOB, failuremsg BLOB, malformed_onion INTEGER, hstate INTEGER, shared_secret BLOB, PRIMARY KEY (id), UNIQUE (channel_id, channel_htlc_id, direction));",
.query = "CREATE TABLE channel_htlcs ( id BIGSERIAL, channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, channel_htlc_id BIGINT, direction INTEGER, origin_htlc BIGINT, msatoshi BIGINT, cltv_expiry INTEGER, payment_hash BYTEA, payment_key BYTEA, routing_onion BYTEA, failuremsg BYTEA, malformed_onion INTEGER, hstate INTEGER, shared_secret BYTEA, PRIMARY KEY (id), UNIQUE (channel_id, channel_htlc_id, direction));",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE invoices ( id BIGSERIAL, state INTEGER, msatoshi BIGINT, payment_hash BLOB, payment_key BLOB, label TEXT, PRIMARY KEY (id), UNIQUE (label), UNIQUE (payment_hash));",
.query = "CREATE TABLE invoices ( id BIGSERIAL, state INTEGER, msatoshi BIGINT, payment_hash BYTEA, payment_key BYTEA, label TEXT, PRIMARY KEY (id), UNIQUE (label), UNIQUE (payment_hash));",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE payments ( id BIGSERIAL, timestamp INTEGER, status INTEGER, payment_hash BLOB, direction INTEGER, destination BLOB, msatoshi BIGINT, PRIMARY KEY (id), UNIQUE (payment_hash));",
.query = "CREATE TABLE payments ( id BIGSERIAL, timestamp INTEGER, status INTEGER, payment_hash BYTEA, direction INTEGER, destination BYTEA, msatoshi BIGINT, PRIMARY KEY (id), UNIQUE (payment_hash));",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE invoices ADD expiry_time BIGINT;",
.query = "ALTER TABLE invoices ADD expiry_time BIGINT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE invoices SET expiry_time=9223372036854775807;",
.query = "UPDATE invoices SET expiry_time=9223372036854775807;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE invoices ADD pay_index BIGINT;",
.query = "ALTER TABLE invoices ADD pay_index BIGINT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE UNIQUE INDEX invoices_pay_index ON invoices(pay_index);",
.query = "CREATE UNIQUE INDEX invoices_pay_index ON invoices(pay_index);",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE invoices SET pay_index=id WHERE state=1;",
.query = "UPDATE invoices SET pay_index=id WHERE state=1;",
.placeholders = 0,
.readonly = false,
},
{
.name = "INSERT INTO vars(name, val) VALUES('next_pay_index', COALESCE((SELECT MAX(pay_index) FROM invoices WHERE state=1), 0) + 1 );",
.query = "INSERT INTO vars(name, val) VALUES('next_pay_index', COALESCE((SELECT MAX(pay_index) FROM invoices WHERE state=1), 0) + 1 );",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD first_blocknum BIGINT;",
.query = "ALTER TABLE channels ADD first_blocknum BIGINT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE channels SET first_blocknum=1 WHERE short_channel_id IS NOT NULL;",
.query = "UPDATE channels SET first_blocknum=1 WHERE short_channel_id IS NOT NULL;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE outputs ADD COLUMN channel_id BIGINT;",
.query = "ALTER TABLE outputs ADD COLUMN channel_id BIGINT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE outputs ADD COLUMN peer_id BLOB;",
.query = "ALTER TABLE outputs ADD COLUMN peer_id BYTEA;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE outputs ADD COLUMN commitment_point BLOB;",
.query = "ALTER TABLE outputs ADD COLUMN commitment_point BYTEA;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE invoices ADD COLUMN msatoshi_received BIGINT;",
.query = "ALTER TABLE invoices ADD COLUMN msatoshi_received BIGINT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE invoices SET msatoshi_received=0 WHERE state=1;",
.query = "UPDATE invoices SET msatoshi_received=0 WHERE state=1;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD COLUMN last_was_revoke INTEGER;",
.query = "ALTER TABLE channels ADD COLUMN last_was_revoke INTEGER;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments RENAME TO temp_payments;",
.query = "ALTER TABLE payments RENAME TO temp_payments;",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE payments ( id BIGSERIAL, timestamp INTEGER, status INTEGER, payment_hash BLOB, destination BLOB, msatoshi BIGINT, PRIMARY KEY (id), UNIQUE (payment_hash));",
.query = "CREATE TABLE payments ( id BIGSERIAL, timestamp INTEGER, status INTEGER, payment_hash BYTEA, destination BYTEA, msatoshi BIGINT, PRIMARY KEY (id), UNIQUE (payment_hash));",
.placeholders = 0,
.readonly = false,
},
{
.name = "INSERT INTO payments SELECT id, timestamp, status, payment_hash, destination, msatoshi FROM temp_payments WHERE direction=1;",
.query = "INSERT INTO payments SELECT id, timestamp, status, payment_hash, destination, msatoshi FROM temp_payments WHERE direction=1;",
.placeholders = 0,
.readonly = false,
},
{
.name = "DROP TABLE temp_payments;",
.query = "DROP TABLE temp_payments;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments ADD COLUMN payment_preimage BLOB;",
.query = "ALTER TABLE payments ADD COLUMN payment_preimage BYTEA;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments ADD COLUMN path_secrets BLOB;",
.query = "ALTER TABLE payments ADD COLUMN path_secrets BYTEA;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE invoices ADD paid_timestamp BIGINT;",
.query = "ALTER TABLE invoices ADD paid_timestamp BIGINT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE invoices SET paid_timestamp = CURRENT_TIMESTAMP() WHERE state = 1;",
.query = "UPDATE invoices SET paid_timestamp = EXTRACT(epoch FROM now()) WHERE state = 1;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments ADD COLUMN route_nodes BLOB;",
.query = "ALTER TABLE payments ADD COLUMN route_nodes BYTEA;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments ADD COLUMN route_channels BLOB;",
.query = "ALTER TABLE payments ADD COLUMN route_channels BYTEA;",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE htlc_sigs (channelid INTEGER REFERENCES channels(id) ON DELETE CASCADE, signature BLOB);",
.query = "CREATE TABLE htlc_sigs (channelid INTEGER REFERENCES channels(id) ON DELETE CASCADE, signature BYTEA);",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE INDEX channel_idx ON htlc_sigs (channelid)",
.query = "CREATE INDEX channel_idx ON htlc_sigs (channelid)",
.placeholders = 0,
.readonly = false,
},
{
.name = "DELETE FROM channels WHERE state=1",
.query = "DELETE FROM channels WHERE state=1",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE db_upgrades (upgrade_from INTEGER, lightning_version TEXT);",
.query = "CREATE TABLE db_upgrades (upgrade_from INTEGER, lightning_version TEXT);",
.placeholders = 0,
.readonly = false,
},
{
.name = "DELETE FROM peers WHERE id NOT IN (SELECT peer_id FROM channels);",
.query = "DELETE FROM peers WHERE id NOT IN (SELECT peer_id FROM channels);",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE channels SET STATE = 8 WHERE state > 8;",
.query = "UPDATE channels SET STATE = 8 WHERE state > 8;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE invoices ADD bolt11 TEXT;",
.query = "ALTER TABLE invoices ADD bolt11 TEXT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE blocks (height INT, hash BLOB, prev_hash BLOB, UNIQUE(height));",
.query = "CREATE TABLE blocks (height INT, hash BYTEA, prev_hash BYTEA, UNIQUE(height));",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE outputs ADD COLUMN confirmation_height INTEGER REFERENCES blocks(height) ON DELETE SET NULL;",
.query = "ALTER TABLE outputs ADD COLUMN confirmation_height INTEGER REFERENCES blocks(height) ON DELETE SET NULL;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE outputs ADD COLUMN spend_height INTEGER REFERENCES blocks(height) ON DELETE SET NULL;",
.query = "ALTER TABLE outputs ADD COLUMN spend_height INTEGER REFERENCES blocks(height) ON DELETE SET NULL;",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE INDEX output_height_idx ON outputs (confirmation_height, spend_height);",
.query = "CREATE INDEX output_height_idx ON outputs (confirmation_height, spend_height);",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE utxoset ( txid BLOB, outnum INT, blockheight INT REFERENCES blocks(height) ON DELETE CASCADE, spendheight INT REFERENCES blocks(height) ON DELETE SET NULL, txindex INT, scriptpubkey BLOB, satoshis BIGINT, PRIMARY KEY(txid, outnum));",
.query = "CREATE TABLE utxoset ( txid BYTEA, outnum INT, blockheight INT REFERENCES blocks(height) ON DELETE CASCADE, spendheight INT REFERENCES blocks(height) ON DELETE SET NULL, txindex INT, scriptpubkey BYTEA, satoshis BIGINT, PRIMARY KEY(txid, outnum));",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE INDEX short_channel_id ON utxoset (blockheight, txindex, outnum)",
.query = "CREATE INDEX short_channel_id ON utxoset (blockheight, txindex, outnum)",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE INDEX utxoset_spend ON utxoset (spendheight)",
.query = "CREATE INDEX utxoset_spend ON utxoset (spendheight)",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE channels SET shutdown_keyidx_local=0 WHERE shutdown_keyidx_local = -1;",
.query = "UPDATE channels SET shutdown_keyidx_local=0 WHERE shutdown_keyidx_local = -1;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments ADD failonionreply BLOB;",
.query = "ALTER TABLE payments ADD failonionreply BYTEA;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments ADD faildestperm INTEGER;",
.query = "ALTER TABLE payments ADD faildestperm INTEGER;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments ADD failindex INTEGER;",
.query = "ALTER TABLE payments ADD failindex INTEGER;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments ADD failcode INTEGER;",
.query = "ALTER TABLE payments ADD failcode INTEGER;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments ADD failnode BLOB;",
.query = "ALTER TABLE payments ADD failnode BYTEA;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments ADD failchannel TEXT;",
.query = "ALTER TABLE payments ADD failchannel TEXT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments ADD failupdate BLOB;",
.query = "ALTER TABLE payments ADD failupdate BYTEA;",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE payments SET path_secrets = NULL , route_nodes = NULL , route_channels = NULL WHERE status <> 0;",
.query = "UPDATE payments SET path_secrets = NULL , route_nodes = NULL , route_channels = NULL WHERE status <> 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD in_payments_offered INTEGER DEFAULT 0;",
.query = "ALTER TABLE channels ADD in_payments_offered INTEGER DEFAULT 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD in_payments_fulfilled INTEGER DEFAULT 0;",
.query = "ALTER TABLE channels ADD in_payments_fulfilled INTEGER DEFAULT 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD in_msatoshi_offered BIGINT DEFAULT 0;",
.query = "ALTER TABLE channels ADD in_msatoshi_offered BIGINT DEFAULT 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD in_msatoshi_fulfilled BIGINT DEFAULT 0;",
.query = "ALTER TABLE channels ADD in_msatoshi_fulfilled BIGINT DEFAULT 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD out_payments_offered INTEGER DEFAULT 0;",
.query = "ALTER TABLE channels ADD out_payments_offered INTEGER DEFAULT 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD out_payments_fulfilled INTEGER DEFAULT 0;",
.query = "ALTER TABLE channels ADD out_payments_fulfilled INTEGER DEFAULT 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD out_msatoshi_offered BIGINT DEFAULT 0;",
.query = "ALTER TABLE channels ADD out_msatoshi_offered BIGINT DEFAULT 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD out_msatoshi_fulfilled BIGINT DEFAULT 0;",
.query = "ALTER TABLE channels ADD out_msatoshi_fulfilled BIGINT DEFAULT 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE channels SET in_payments_offered = 0, in_payments_fulfilled = 0 , in_msatoshi_offered = 0, in_msatoshi_fulfilled = 0 , out_payments_offered = 0, out_payments_fulfilled = 0 , out_msatoshi_offered = 0, out_msatoshi_fulfilled = 0 ;",
.query = "UPDATE channels SET in_payments_offered = 0, in_payments_fulfilled = 0 , in_msatoshi_offered = 0, in_msatoshi_fulfilled = 0 , out_payments_offered = 0, out_payments_fulfilled = 0 , out_msatoshi_offered = 0, out_msatoshi_fulfilled = 0 ;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments ADD msatoshi_sent BIGINT;",
.query = "ALTER TABLE payments ADD msatoshi_sent BIGINT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE payments SET msatoshi_sent = msatoshi;",
.query = "UPDATE payments SET msatoshi_sent = msatoshi;",
.placeholders = 0,
.readonly = false,
},
{
.name = "DELETE FROM utxoset WHERE blockheight IN ( SELECT DISTINCT(blockheight) FROM utxoset LEFT OUTER JOIN blocks on (blockheight = blocks.height) WHERE blocks.hash IS NULL);",
.query = "DELETE FROM utxoset WHERE blockheight IN ( SELECT DISTINCT(blockheight) FROM utxoset LEFT OUTER JOIN blocks on (blockheight = blocks.height) WHERE blocks.hash IS NULL);",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD min_possible_feerate INTEGER;",
.query = "ALTER TABLE channels ADD min_possible_feerate INTEGER;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD max_possible_feerate INTEGER;",
.query = "ALTER TABLE channels ADD max_possible_feerate INTEGER;",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE channels SET min_possible_feerate=0, max_possible_feerate=250000;",
.query = "UPDATE channels SET min_possible_feerate=0, max_possible_feerate=250000;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD msatoshi_to_us_min BIGINT;",
.query = "ALTER TABLE channels ADD msatoshi_to_us_min BIGINT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD msatoshi_to_us_max BIGINT;",
.query = "ALTER TABLE channels ADD msatoshi_to_us_max BIGINT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE channels SET msatoshi_to_us_min = msatoshi_local , msatoshi_to_us_max = msatoshi_local ;",
.query = "UPDATE channels SET msatoshi_to_us_min = msatoshi_local , msatoshi_to_us_max = msatoshi_local ;",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE transactions ( id BLOB, blockheight INTEGER REFERENCES blocks(height) ON DELETE SET NULL, txindex INTEGER, rawtx BLOB, PRIMARY KEY (id));",
.query = "CREATE TABLE transactions ( id BYTEA, blockheight INTEGER REFERENCES blocks(height) ON DELETE SET NULL, txindex INTEGER, rawtx BYTEA, PRIMARY KEY (id));",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments ADD faildetail TEXT;",
.query = "ALTER TABLE payments ADD faildetail TEXT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE payments SET faildetail = 'unspecified payment failure reason' WHERE status = 2;",
.query = "UPDATE payments SET faildetail = 'unspecified payment failure reason' WHERE status = 2;",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE channeltxs ( id BIGSERIAL, channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, type INTEGER, transaction_id BLOB REFERENCES transactions(id) ON DELETE CASCADE, input_num INTEGER, blockheight INTEGER REFERENCES blocks(height) ON DELETE CASCADE, PRIMARY KEY(id));",
.query = "CREATE TABLE channeltxs ( id BIGSERIAL, channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, type INTEGER, transaction_id BYTEA REFERENCES transactions(id) ON DELETE CASCADE, input_num INTEGER, blockheight INTEGER REFERENCES blocks(height) ON DELETE CASCADE, PRIMARY KEY(id));",
.placeholders = 0,
.readonly = false,
},
{
.name = "DELETE FROM blocks WHERE height > (SELECT MIN(first_blocknum) FROM channels);",
.query = "DELETE FROM blocks WHERE height > (SELECT MIN(first_blocknum) FROM channels);",
.placeholders = 0,
.readonly = false,
},
{
.name = "INSERT INTO blocks (height) VALUES ((SELECT MIN(first_blocknum) FROM channels)) ON CONFLICT(height) DO NOTHING;",
.query = "INSERT INTO blocks (height) VALUES ((SELECT MIN(first_blocknum) FROM channels)) ON CONFLICT(height) DO NOTHING;",
.placeholders = 0,
.readonly = false,
},
{
.name = "DELETE FROM blocks WHERE height IS NULL;",
.query = "DELETE FROM blocks WHERE height IS NULL;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE invoices ADD description TEXT;",
.query = "ALTER TABLE invoices ADD description TEXT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments ADD description TEXT;",
.query = "ALTER TABLE payments ADD description TEXT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD future_per_commitment_point BLOB;",
.query = "ALTER TABLE channels ADD future_per_commitment_point BYTEA;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD last_sent_commit BLOB;",
.query = "ALTER TABLE channels ADD last_sent_commit BYTEA;",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE forwarded_payments ( in_htlc_id BIGINT REFERENCES channel_htlcs(id) ON DELETE SET NULL, out_htlc_id BIGINT REFERENCES channel_htlcs(id) ON DELETE SET NULL, in_channel_scid BIGINT, out_channel_scid BIGINT, in_msatoshi BIGINT, out_msatoshi BIGINT, state INTEGER, UNIQUE(in_htlc_id, out_htlc_id));",
.query = "CREATE TABLE forwarded_payments ( in_htlc_id BIGINT REFERENCES channel_htlcs(id) ON DELETE SET NULL, out_htlc_id BIGINT REFERENCES channel_htlcs(id) ON DELETE SET NULL, in_channel_scid BIGINT, out_channel_scid BIGINT, in_msatoshi BIGINT, out_msatoshi BIGINT, state INTEGER, UNIQUE(in_htlc_id, out_htlc_id));",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments ADD faildirection INTEGER;",
.query = "ALTER TABLE payments ADD faildirection INTEGER;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE outputs ADD scriptpubkey BLOB;",
.query = "ALTER TABLE outputs ADD scriptpubkey BYTEA;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments ADD bolt11 TEXT;",
.query = "ALTER TABLE payments ADD bolt11 TEXT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD feerate_base INTEGER;",
.query = "ALTER TABLE channels ADD feerate_base INTEGER;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD feerate_ppm INTEGER;",
.query = "ALTER TABLE channels ADD feerate_ppm INTEGER;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channel_htlcs ADD received_time BIGINT",
.query = "ALTER TABLE channel_htlcs ADD received_time BIGINT",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE forwarded_payments ADD received_time BIGINT",
.query = "ALTER TABLE forwarded_payments ADD received_time BIGINT",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE forwarded_payments ADD resolved_time BIGINT",
.query = "ALTER TABLE forwarded_payments ADD resolved_time BIGINT",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD remote_upfront_shutdown_script BLOB;",
.query = "ALTER TABLE channels ADD remote_upfront_shutdown_script BYTEA;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE forwarded_payments ADD failcode INTEGER;",
.query = "ALTER TABLE forwarded_payments ADD failcode INTEGER;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD remote_ann_node_sig BLOB;",
.query = "ALTER TABLE channels ADD remote_ann_node_sig BYTEA;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD remote_ann_bitcoin_sig BLOB;",
.query = "ALTER TABLE channels ADD remote_ann_bitcoin_sig BYTEA;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE transactions ADD type BIGINT;",
.query = "ALTER TABLE transactions ADD type BIGINT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE transactions ADD channel_id BIGINT;",
.query = "ALTER TABLE transactions ADD channel_id BIGINT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE channels SET short_channel_id = REPLACE(short_channel_id, ':', 'x') WHERE short_channel_id IS NOT NULL;",
.query = "UPDATE channels SET short_channel_id = REPLACE(short_channel_id, ':', 'x') WHERE short_channel_id IS NOT NULL;",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE payments SET failchannel = REPLACE(failchannel, ':', 'x') WHERE failchannel IS NOT NULL;",
.query = "UPDATE payments SET failchannel = REPLACE(failchannel, ':', 'x') WHERE failchannel IS NOT NULL;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD COLUMN option_static_remotekey INTEGER DEFAULT 0;",
.query = "ALTER TABLE channels ADD COLUMN option_static_remotekey INTEGER DEFAULT 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE vars ADD COLUMN intval INTEGER",
.query = "ALTER TABLE vars ADD COLUMN intval INTEGER",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE vars ADD COLUMN blobval BLOB",
.query = "ALTER TABLE vars ADD COLUMN blobval BYTEA",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE vars SET intval = CAST(val AS INTEGER) WHERE name IN ('bip32_max_index', 'last_processed_block', 'next_pay_index')",
.query = "UPDATE vars SET intval = CAST(val AS INTEGER) WHERE name IN ('bip32_max_index', 'last_processed_block', 'next_pay_index')",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE vars SET blobval = CAST(val AS BLOB) WHERE name = 'genesis_hash'",
.query = "UPDATE vars SET blobval = CAST(val AS BYTEA) WHERE name = 'genesis_hash'",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE transaction_annotations ( txid BLOB, idx INTEGER, location INTEGER, type INTEGER, channel BIGINT REFERENCES channels(id), UNIQUE(txid, idx));",
.query = "CREATE TABLE transaction_annotations ( txid BYTEA, idx INTEGER, location INTEGER, type INTEGER, channel BIGINT REFERENCES channels(id), UNIQUE(txid, idx));",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD shutdown_scriptpubkey_local BLOB;",
.query = "ALTER TABLE channels ADD shutdown_scriptpubkey_local BYTEA;",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE forwarded_payments SET received_time=0 WHERE received_time IS NULL;",
.query = "UPDATE forwarded_payments SET received_time=0 WHERE received_time IS NULL;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE invoices ADD COLUMN features BLOB DEFAULT '';",
.query = "ALTER TABLE invoices ADD COLUMN features BYTEA DEFAULT '';",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE payments ( id BIGSERIAL, timestamp INTEGER, status INTEGER, payment_hash BLOB, destination BLOB, msatoshi BIGINT, payment_preimage BLOB, path_secrets BLOB, route_nodes BLOB, route_channels BLOB, failonionreply BLOB, faildestperm INTEGER, failindex INTEGER, failcode INTEGER, failnode BLOB, failchannel TEXT, failupdate BLOB, msatoshi_sent BIGINT, faildetail TEXT, description TEXT, faildirection INTEGER, bolt11 TEXT, total_msat BIGINT, partid BIGINT, PRIMARY KEY (id), UNIQUE (payment_hash, partid))",
.query = "CREATE TABLE payments ( id BIGSERIAL, timestamp INTEGER, status INTEGER, payment_hash BYTEA, destination BYTEA, msatoshi BIGINT, payment_preimage BYTEA, path_secrets BYTEA, route_nodes BYTEA, route_channels BYTEA, failonionreply BYTEA, faildestperm INTEGER, failindex INTEGER, failcode INTEGER, failnode BYTEA, failchannel TEXT, failupdate BYTEA, msatoshi_sent BIGINT, faildetail TEXT, description TEXT, faildirection INTEGER, bolt11 TEXT, total_msat BIGINT, partid BIGINT, PRIMARY KEY (id), UNIQUE (payment_hash, partid))",
.placeholders = 0,
.readonly = false,
},
{
.name = "INSERT INTO payments (id, timestamp, status, payment_hash, destination, msatoshi, payment_preimage, path_secrets, route_nodes, route_channels, failonionreply, faildestperm, failindex, failcode, failnode, failchannel, failupdate, msatoshi_sent, faildetail, description, faildirection, bolt11)SELECT id, timestamp, status, payment_hash, destination, msatoshi, payment_preimage, path_secrets, route_nodes, route_channels, failonionreply, faildestperm, failindex, failcode, failnode, failchannel, failupdate, msatoshi_sent, faildetail, description, faildirection, bolt11 FROM temp_payments;",
.query = "INSERT INTO payments (id, timestamp, status, payment_hash, destination, msatoshi, payment_preimage, path_secrets, route_nodes, route_channels, failonionreply, faildestperm, failindex, failcode, failnode, failchannel, failupdate, msatoshi_sent, faildetail, description, faildirection, bolt11)SELECT id, timestamp, status, payment_hash, destination, msatoshi, payment_preimage, path_secrets, route_nodes, route_channels, failonionreply, faildestperm, failindex, failcode, failnode, failchannel, failupdate, msatoshi_sent, faildetail, description, faildirection, bolt11 FROM temp_payments;",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE payments SET total_msat = msatoshi;",
.query = "UPDATE payments SET total_msat = msatoshi;",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE payments SET partid = 0;",
.query = "UPDATE payments SET partid = 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channel_htlcs ADD partid BIGINT;",
.query = "ALTER TABLE channel_htlcs ADD partid BIGINT;",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE channel_htlcs SET partid = 0;",
.query = "UPDATE channel_htlcs SET partid = 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE channel_feerates ( channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, hstate INTEGER, feerate_per_kw INTEGER, UNIQUE (channel_id, hstate));",
.query = "CREATE TABLE channel_feerates ( channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, hstate INTEGER, feerate_per_kw INTEGER, UNIQUE (channel_id, hstate));",
.placeholders = 0,
.readonly = false,
},
{
.name = "INSERT INTO channel_feerates(channel_id, hstate, feerate_per_kw) SELECT id, 4, local_feerate_per_kw FROM channels WHERE funder = 0;",
.query = "INSERT INTO channel_feerates(channel_id, hstate, feerate_per_kw) SELECT id, 4, local_feerate_per_kw FROM channels WHERE funder = 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "INSERT INTO channel_feerates(channel_id, hstate, feerate_per_kw) SELECT id, 1, remote_feerate_per_kw FROM channels WHERE funder = 0 and local_feerate_per_kw != remote_feerate_per_kw;",
.query = "INSERT INTO channel_feerates(channel_id, hstate, feerate_per_kw) SELECT id, 1, remote_feerate_per_kw FROM channels WHERE funder = 0 and local_feerate_per_kw != remote_feerate_per_kw;",
.placeholders = 0,
.readonly = false,
},
{
.name = "INSERT INTO channel_feerates(channel_id, hstate, feerate_per_kw) SELECT id, 14, remote_feerate_per_kw FROM channels WHERE funder = 1;",
.query = "INSERT INTO channel_feerates(channel_id, hstate, feerate_per_kw) SELECT id, 14, remote_feerate_per_kw FROM channels WHERE funder = 1;",
.placeholders = 0,
.readonly = false,
},
{
.name = "INSERT INTO channel_feerates(channel_id, hstate, feerate_per_kw) SELECT id, 11, local_feerate_per_kw FROM channels WHERE funder = 1 and local_feerate_per_kw != remote_feerate_per_kw;",
.query = "INSERT INTO channel_feerates(channel_id, hstate, feerate_per_kw) SELECT id, 11, local_feerate_per_kw FROM channels WHERE funder = 1 and local_feerate_per_kw != remote_feerate_per_kw;",
.placeholders = 0,
.readonly = false,
},
{
.name = "INSERT INTO vars (name, intval) VALUES ('data_version', 0);",
.query = "INSERT INTO vars (name, intval) VALUES ('data_version', 0);",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channel_htlcs ADD localfailmsg BLOB;",
.query = "ALTER TABLE channel_htlcs ADD localfailmsg BYTEA;",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE channel_htlcs SET localfailmsg=decode('2002', 'hex') WHERE malformed_onion != 0 AND direction = 1;",
.query = "UPDATE channel_htlcs SET localfailmsg=decode('2002', 'hex') WHERE malformed_onion != 0 AND direction = 1;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD our_funding_satoshi BIGINT DEFAULT 0;",
.query = "ALTER TABLE channels ADD our_funding_satoshi BIGINT DEFAULT 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE penalty_bases ( channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, commitnum BIGINT, txid BLOB, outnum INTEGER, amount BIGINT, PRIMARY KEY (channel_id, commitnum));",
.query = "CREATE TABLE penalty_bases ( channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, commitnum BIGINT, txid BYTEA, outnum INTEGER, amount BIGINT, PRIMARY KEY (channel_id, commitnum));",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channel_htlcs ADD we_filled INTEGER;",
.query = "ALTER TABLE channel_htlcs ADD we_filled INTEGER;",
.placeholders = 0,
.readonly = false,
},
{
.name = "INSERT INTO vars (name, intval) VALUES ('coin_moves_count', 0);",
.query = "INSERT INTO vars (name, intval) VALUES ('coin_moves_count', 0);",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE outputs ADD reserved_til INTEGER DEFAULT NULL;",
.query = "ALTER TABLE outputs ADD reserved_til INTEGER DEFAULT NULL;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD COLUMN option_anchor_outputs INTEGER DEFAULT 0;",
.query = "ALTER TABLE channels ADD COLUMN option_anchor_outputs INTEGER DEFAULT 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE outputs ADD option_anchor_outputs INTEGER DEFAULT 0;",
.query = "ALTER TABLE outputs ADD option_anchor_outputs INTEGER DEFAULT 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD full_channel_id BLOB DEFAULT NULL;",
.query = "ALTER TABLE channels ADD full_channel_id BYTEA DEFAULT NULL;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD funding_psbt BLOB DEFAULT NULL;",
.query = "ALTER TABLE channels ADD funding_psbt BYTEA DEFAULT NULL;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD closer INTEGER DEFAULT 2;",
.query = "ALTER TABLE channels ADD closer INTEGER DEFAULT 2;",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD state_change_reason INTEGER DEFAULT 0;",
.query = "ALTER TABLE channels ADD state_change_reason INTEGER DEFAULT 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE channel_state_changes ( channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, timestamp BIGINT, old_state INTEGER, new_state INTEGER, cause INTEGER, message TEXT);",
.query = "CREATE TABLE channel_state_changes ( channel_id BIGINT REFERENCES channels(id) ON DELETE CASCADE, timestamp BIGINT, old_state INTEGER, new_state INTEGER, cause INTEGER, message TEXT);",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE offers ( offer_id BLOB, bolt12 TEXT, label TEXT, status INTEGER, PRIMARY KEY (offer_id));",
.query = "CREATE TABLE offers ( offer_id BYTEA, bolt12 TEXT, label TEXT, status INTEGER, PRIMARY KEY (offer_id));",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE invoices ADD COLUMN local_offer_id BLOB DEFAULT NULL REFERENCES offers(offer_id);",
.query = "ALTER TABLE invoices ADD COLUMN local_offer_id BYTEA DEFAULT NULL REFERENCES offers(offer_id);",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE payments ADD COLUMN local_offer_id BLOB DEFAULT NULL REFERENCES offers(offer_id);",
.query = "ALTER TABLE payments ADD COLUMN local_offer_id BYTEA DEFAULT NULL REFERENCES offers(offer_id);",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD funding_tx_remote_sigs_received INTEGER DEFAULT 0;",
.query = "ALTER TABLE channels ADD funding_tx_remote_sigs_received INTEGER DEFAULT 0;",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE INDEX forwarded_payments_out_htlc_id ON forwarded_payments (out_htlc_id);",
.query = "CREATE INDEX forwarded_payments_out_htlc_id ON forwarded_payments (out_htlc_id);",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE channel_htlcs SET malformed_onion = 0 WHERE malformed_onion IS NULL",
.query = "UPDATE channel_htlcs SET malformed_onion = 0 WHERE malformed_onion IS NULL",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE INDEX forwarded_payments_state ON forwarded_payments (state)",
.query = "CREATE INDEX forwarded_payments_state ON forwarded_payments (state)",
.placeholders = 0,
.readonly = false,
},
{
.name = "CREATE TABLE channel_funding_inflights ( channel_id BIGSERIAL REFERENCES channels(id) ON DELETE CASCADE, funding_tx_id BLOB, funding_tx_outnum INTEGER, funding_feerate INTEGER, funding_satoshi BIGINT, our_funding_satoshi BIGINT, funding_psbt BLOB, last_tx BLOB, last_sig BLOB, funding_tx_remote_sigs_received INTEGER, PRIMARY KEY (channel_id, funding_tx_id));",
.query = "CREATE TABLE channel_funding_inflights ( channel_id BIGSERIAL REFERENCES channels(id) ON DELETE CASCADE, funding_tx_id BYTEA, funding_tx_outnum INTEGER, funding_feerate INTEGER, funding_satoshi BIGINT, our_funding_satoshi BIGINT, funding_psbt BYTEA, last_tx BYTEA, last_sig BYTEA, funding_tx_remote_sigs_received INTEGER, PRIMARY KEY (channel_id, funding_tx_id));",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD revocation_basepoint_local BLOB",
.query = "ALTER TABLE channels ADD revocation_basepoint_local BYTEA",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD payment_basepoint_local BLOB",
.query = "ALTER TABLE channels ADD payment_basepoint_local BYTEA",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD htlc_basepoint_local BLOB",
.query = "ALTER TABLE channels ADD htlc_basepoint_local BYTEA",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD delayed_payment_basepoint_local BLOB",
.query = "ALTER TABLE channels ADD delayed_payment_basepoint_local BYTEA",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD funding_pubkey_local BLOB",
.query = "ALTER TABLE channels ADD funding_pubkey_local BYTEA",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD shutdown_wrong_txid BLOB DEFAULT NULL",
.query = "ALTER TABLE channels ADD shutdown_wrong_txid BYTEA DEFAULT NULL",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD shutdown_wrong_outnum INTEGER DEFAULT NULL",
.query = "ALTER TABLE channels ADD shutdown_wrong_outnum INTEGER DEFAULT NULL",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD local_static_remotekey_start BIGINT DEFAULT 0",
.query = "ALTER TABLE channels ADD local_static_remotekey_start BIGINT DEFAULT 0",
.placeholders = 0,
.readonly = false,
},
{
.name = "ALTER TABLE channels ADD remote_static_remotekey_start BIGINT DEFAULT 0",
.query = "ALTER TABLE channels ADD remote_static_remotekey_start BIGINT DEFAULT 0",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE channels SET remote_static_remotekey_start = 9223372036854775807, local_static_remotekey_start = 9223372036854775807 WHERE option_static_remotekey = 0",
.query = "UPDATE channels SET remote_static_remotekey_start = 9223372036854775807, local_static_remotekey_start = 9223372036854775807 WHERE option_static_remotekey = 0",
.placeholders = 0,
.readonly = false,
},
{
.name = "UPDATE vars SET intval = intval + 1 WHERE name = 'data_version' AND intval = ?",
.query = "UPDATE vars SET intval = intval + 1 WHERE name = 'data_version' AND intval = $1",
.placeholders = 1,
.readonly = false,
},
{
.name = "SELECT version FROM version LIMIT 1",
.query = "SELECT version FROM version LIMIT 1",
.placeholders = 0,
.readonly = true,
},
{
.name = "UPDATE version SET version=?;",
.query = "UPDATE version SET version=$1;",
.placeholders = 1,
.readonly = false,
},
{
.name = "INSERT INTO db_upgrades VALUES (?, ?);",
.query = "INSERT INTO db_upgrades VALUES ($1, $2);",
.placeholders = 2,
.readonly = false,
},
{
.name = "SELECT intval FROM vars WHERE name = 'data_version'",
.query = "SELECT intval FROM vars WHERE name = 'data_version'",
.placeholders = 0,
.readonly = true,
},
{
.name = "SELECT intval FROM vars WHERE name= ? LIMIT 1",
.query = "SELECT intval FROM vars WHERE name= $1 LIMIT 1",
.placeholders = 1,
.readonly = true,
},
{
.name = "UPDATE vars SET intval=? WHERE name=?;",
.query = "UPDATE vars SET intval=$1 WHERE name=$2;",
.placeholders = 2,
.readonly = false,
},