-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathschema.sql
2818 lines (1934 loc) · 89.1 KB
/
schema.sql
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
--
-- PostgreSQL database dump
--
-- Dumped from database version 15.4
-- Dumped by pg_dump version 15.6 (Homebrew)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: stacks_blockchain_api; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA stacks_blockchain_api;
ALTER SCHEMA stacks_blockchain_api OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: blocks; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.blocks (
index_block_hash bytea NOT NULL,
block_hash bytea NOT NULL,
block_height integer NOT NULL,
burn_block_time integer NOT NULL,
burn_block_hash bytea NOT NULL,
burn_block_height integer NOT NULL,
miner_txid bytea NOT NULL,
parent_index_block_hash bytea NOT NULL,
parent_block_hash bytea NOT NULL,
parent_microblock_hash bytea NOT NULL,
parent_microblock_sequence integer NOT NULL,
canonical boolean NOT NULL,
execution_cost_read_count bigint NOT NULL,
execution_cost_read_length bigint NOT NULL,
execution_cost_runtime bigint NOT NULL,
execution_cost_write_count bigint NOT NULL,
execution_cost_write_length bigint NOT NULL,
tx_count integer DEFAULT 1 NOT NULL
);
ALTER TABLE stacks_blockchain_api.blocks OWNER TO stacks;
--
-- Name: burnchain_rewards; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.burnchain_rewards (
id integer NOT NULL,
canonical boolean NOT NULL,
burn_block_hash bytea NOT NULL,
burn_block_height integer NOT NULL,
burn_amount numeric NOT NULL,
reward_recipient text NOT NULL,
reward_amount numeric NOT NULL,
reward_index integer NOT NULL
);
ALTER TABLE stacks_blockchain_api.burnchain_rewards OWNER TO stacks;
--
-- Name: burnchain_rewards_id_seq; Type: SEQUENCE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE SEQUENCE stacks_blockchain_api.burnchain_rewards_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE stacks_blockchain_api.burnchain_rewards_id_seq OWNER TO stacks;
--
-- Name: burnchain_rewards_id_seq; Type: SEQUENCE OWNED BY; Schema: stacks_blockchain_api; Owner: stacks
--
ALTER SEQUENCE stacks_blockchain_api.burnchain_rewards_id_seq OWNED BY stacks_blockchain_api.burnchain_rewards.id;
--
-- Name: chain_tip; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.chain_tip (
id boolean DEFAULT true NOT NULL,
block_height integer NOT NULL,
block_count integer NOT NULL,
block_hash bytea NOT NULL,
index_block_hash bytea NOT NULL,
burn_block_height integer NOT NULL,
microblock_hash bytea,
microblock_sequence integer,
microblock_count integer NOT NULL,
tx_count integer NOT NULL,
tx_count_unanchored integer NOT NULL,
mempool_tx_count integer DEFAULT 0 NOT NULL,
mempool_updated_at timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT chain_tip_one_row CHECK (id)
);
ALTER TABLE stacks_blockchain_api.chain_tip OWNER TO stacks;
--
-- Name: config_state; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.config_state (
id boolean DEFAULT true NOT NULL,
bns_names_onchain_imported boolean DEFAULT false NOT NULL,
bns_subdomains_imported boolean DEFAULT false NOT NULL,
token_offering_imported boolean DEFAULT false NOT NULL,
CONSTRAINT config_state_one_row CHECK (id)
);
ALTER TABLE stacks_blockchain_api.config_state OWNER TO stacks;
--
-- Name: contract_logs; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.contract_logs (
id integer NOT NULL,
event_index integer NOT NULL,
tx_id bytea NOT NULL,
tx_index smallint NOT NULL,
block_height integer NOT NULL,
index_block_hash bytea NOT NULL,
parent_index_block_hash bytea NOT NULL,
microblock_hash bytea NOT NULL,
microblock_sequence integer NOT NULL,
microblock_canonical boolean NOT NULL,
canonical boolean NOT NULL,
contract_identifier text NOT NULL,
topic text NOT NULL,
value bytea NOT NULL
);
ALTER TABLE stacks_blockchain_api.contract_logs OWNER TO stacks;
--
-- Name: contract_logs_id_seq; Type: SEQUENCE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE SEQUENCE stacks_blockchain_api.contract_logs_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE stacks_blockchain_api.contract_logs_id_seq OWNER TO stacks;
--
-- Name: contract_logs_id_seq; Type: SEQUENCE OWNED BY; Schema: stacks_blockchain_api; Owner: stacks
--
ALTER SEQUENCE stacks_blockchain_api.contract_logs_id_seq OWNED BY stacks_blockchain_api.contract_logs.id;
--
-- Name: event_observer_requests; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.event_observer_requests (
id bigint NOT NULL,
receive_timestamp timestamp with time zone DEFAULT (now() AT TIME ZONE 'utc'::text) NOT NULL,
event_path text NOT NULL,
payload jsonb NOT NULL
);
ALTER TABLE stacks_blockchain_api.event_observer_requests OWNER TO stacks;
--
-- Name: event_observer_requests_id_seq; Type: SEQUENCE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE SEQUENCE stacks_blockchain_api.event_observer_requests_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE stacks_blockchain_api.event_observer_requests_id_seq OWNER TO stacks;
--
-- Name: event_observer_requests_id_seq; Type: SEQUENCE OWNED BY; Schema: stacks_blockchain_api; Owner: stacks
--
ALTER SEQUENCE stacks_blockchain_api.event_observer_requests_id_seq OWNED BY stacks_blockchain_api.event_observer_requests.id;
--
-- Name: faucet_requests; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.faucet_requests (
id integer NOT NULL,
currency text NOT NULL,
address text NOT NULL,
ip text NOT NULL,
occurred_at bigint NOT NULL
);
ALTER TABLE stacks_blockchain_api.faucet_requests OWNER TO stacks;
--
-- Name: faucet_requests_id_seq; Type: SEQUENCE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE SEQUENCE stacks_blockchain_api.faucet_requests_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE stacks_blockchain_api.faucet_requests_id_seq OWNER TO stacks;
--
-- Name: faucet_requests_id_seq; Type: SEQUENCE OWNED BY; Schema: stacks_blockchain_api; Owner: stacks
--
ALTER SEQUENCE stacks_blockchain_api.faucet_requests_id_seq OWNED BY stacks_blockchain_api.faucet_requests.id;
--
-- Name: ft_events; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.ft_events (
id integer NOT NULL,
event_index integer NOT NULL,
tx_id bytea NOT NULL,
tx_index smallint NOT NULL,
block_height integer NOT NULL,
index_block_hash bytea NOT NULL,
parent_index_block_hash bytea NOT NULL,
microblock_hash bytea NOT NULL,
microblock_sequence integer NOT NULL,
microblock_canonical boolean NOT NULL,
canonical boolean NOT NULL,
asset_event_type_id smallint NOT NULL,
asset_identifier text NOT NULL,
amount numeric NOT NULL,
sender text,
recipient text,
CONSTRAINT valid_asset_burn CHECK (((asset_event_type_id <> 3) OR ((recipient IS NULL) AND (sender IS NOT NULL)))),
CONSTRAINT valid_asset_mint CHECK (((asset_event_type_id <> 2) OR ((sender IS NULL) AND (recipient IS NOT NULL)))),
CONSTRAINT valid_asset_transfer CHECK (((asset_event_type_id <> 1) OR (NOT (ROW(sender, recipient) IS NULL))))
);
ALTER TABLE stacks_blockchain_api.ft_events OWNER TO stacks;
--
-- Name: ft_events_id_seq; Type: SEQUENCE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE SEQUENCE stacks_blockchain_api.ft_events_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE stacks_blockchain_api.ft_events_id_seq OWNER TO stacks;
--
-- Name: ft_events_id_seq; Type: SEQUENCE OWNED BY; Schema: stacks_blockchain_api; Owner: stacks
--
ALTER SEQUENCE stacks_blockchain_api.ft_events_id_seq OWNED BY stacks_blockchain_api.ft_events.id;
--
-- Name: mempool_txs; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.mempool_txs (
id integer NOT NULL,
pruned boolean NOT NULL,
tx_id bytea NOT NULL,
type_id smallint NOT NULL,
anchor_mode smallint NOT NULL,
status smallint NOT NULL,
post_conditions bytea NOT NULL,
nonce integer NOT NULL,
fee_rate bigint NOT NULL,
sponsored boolean NOT NULL,
sponsor_address text,
sponsor_nonce integer,
sender_address text NOT NULL,
origin_hash_mode smallint NOT NULL,
raw_tx bytea NOT NULL,
receipt_time integer NOT NULL,
receipt_block_height integer NOT NULL,
token_transfer_recipient_address text,
token_transfer_amount bigint,
token_transfer_memo bytea,
smart_contract_clarity_version smallint,
smart_contract_contract_id text,
smart_contract_source_code text,
contract_call_contract_id text,
contract_call_function_name text,
contract_call_function_args bytea,
poison_microblock_header_1 bytea,
poison_microblock_header_2 bytea,
coinbase_payload bytea,
coinbase_alt_recipient text,
tx_size integer GENERATED ALWAYS AS (length(raw_tx)) STORED NOT NULL,
coinbase_vrf_proof bytea,
tenure_change_tenure_consensus_hash bytea,
tenure_change_prev_tenure_consensus_hash bytea,
tenure_change_burn_view_consensus_hash bytea,
tenure_change_previous_tenure_end bytea,
tenure_change_previous_tenure_blocks integer,
tenure_change_cause smallint,
tenure_change_pubkey_hash bytea,
tenure_change_signature bytea,
tenure_change_signers bytea,
CONSTRAINT valid_coinbase CHECK (((type_id <> 4) OR (NOT (coinbase_payload IS NULL)))),
CONSTRAINT "valid_coinbase-pay-to-alt" CHECK (((type_id <> 5) OR (NOT (ROW(coinbase_payload, coinbase_alt_recipient) IS NULL)))),
CONSTRAINT valid_contract_call CHECK (((type_id <> 2) OR (NOT (ROW(contract_call_contract_id, contract_call_function_name, contract_call_function_args) IS NULL)))),
CONSTRAINT "valid_nakamoto-coinbase" CHECK (((type_id <> 8) OR (NOT (ROW(coinbase_payload, coinbase_vrf_proof) IS NULL)))),
CONSTRAINT valid_poison_microblock CHECK (((type_id <> 3) OR (NOT (ROW(poison_microblock_header_1, poison_microblock_header_2) IS NULL)))),
CONSTRAINT valid_smart_contract CHECK (((type_id <> 1) OR (NOT (ROW(smart_contract_contract_id, smart_contract_source_code) IS NULL)))),
CONSTRAINT "valid_tenure-change" CHECK (((type_id <> 7) OR (NOT (ROW(tenure_change_tenure_consensus_hash, tenure_change_prev_tenure_consensus_hash, tenure_change_burn_view_consensus_hash, tenure_change_previous_tenure_end, tenure_change_previous_tenure_blocks, tenure_change_cause, tenure_change_pubkey_hash, tenure_change_signature, tenure_change_signers) IS NULL)))),
CONSTRAINT valid_token_transfer CHECK (((type_id <> 0) OR (NOT (ROW(token_transfer_recipient_address, token_transfer_amount, token_transfer_memo) IS NULL)))),
CONSTRAINT valid_versioned_smart_contract CHECK (((type_id <> 6) OR (NOT (ROW(smart_contract_clarity_version, smart_contract_contract_id, smart_contract_source_code) IS NULL))))
);
ALTER TABLE stacks_blockchain_api.mempool_txs OWNER TO stacks;
--
-- Name: mempool_digest; Type: MATERIALIZED VIEW; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE MATERIALIZED VIEW stacks_blockchain_api.mempool_digest AS
SELECT COALESCE(to_hex(bit_xor(m.tx_short_id)), '0'::text) AS digest
FROM ( SELECT ((('x'::text || encode(mempool_txs.tx_id, 'hex'::text)))::bit(64))::bigint AS tx_short_id
FROM stacks_blockchain_api.mempool_txs
WHERE (mempool_txs.pruned = false)) m
WITH NO DATA;
ALTER TABLE stacks_blockchain_api.mempool_digest OWNER TO stacks;
--
-- Name: mempool_txs_id_seq; Type: SEQUENCE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE SEQUENCE stacks_blockchain_api.mempool_txs_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE stacks_blockchain_api.mempool_txs_id_seq OWNER TO stacks;
--
-- Name: mempool_txs_id_seq; Type: SEQUENCE OWNED BY; Schema: stacks_blockchain_api; Owner: stacks
--
ALTER SEQUENCE stacks_blockchain_api.mempool_txs_id_seq OWNED BY stacks_blockchain_api.mempool_txs.id;
--
-- Name: microblocks; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.microblocks (
id bigint NOT NULL,
receive_timestamp timestamp without time zone DEFAULT (now() AT TIME ZONE 'utc'::text) NOT NULL,
canonical boolean NOT NULL,
microblock_canonical boolean NOT NULL,
microblock_hash bytea NOT NULL,
microblock_sequence integer NOT NULL,
microblock_parent_hash bytea NOT NULL,
index_block_hash bytea NOT NULL,
parent_index_block_hash bytea NOT NULL,
block_height integer NOT NULL,
parent_block_height integer NOT NULL,
parent_block_hash bytea NOT NULL,
parent_burn_block_height integer NOT NULL,
parent_burn_block_time integer NOT NULL,
parent_burn_block_hash bytea NOT NULL,
block_hash bytea NOT NULL
);
ALTER TABLE stacks_blockchain_api.microblocks OWNER TO stacks;
--
-- Name: microblocks_id_seq; Type: SEQUENCE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE SEQUENCE stacks_blockchain_api.microblocks_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE stacks_blockchain_api.microblocks_id_seq OWNER TO stacks;
--
-- Name: microblocks_id_seq; Type: SEQUENCE OWNED BY; Schema: stacks_blockchain_api; Owner: stacks
--
ALTER SEQUENCE stacks_blockchain_api.microblocks_id_seq OWNED BY stacks_blockchain_api.microblocks.id;
--
-- Name: miner_rewards; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.miner_rewards (
id integer NOT NULL,
block_hash bytea NOT NULL,
index_block_hash bytea NOT NULL,
from_index_block_hash bytea NOT NULL,
mature_block_height integer NOT NULL,
canonical boolean NOT NULL,
recipient text NOT NULL,
miner_address text,
coinbase_amount numeric NOT NULL,
tx_fees_anchored numeric NOT NULL,
tx_fees_streamed_confirmed numeric NOT NULL,
tx_fees_streamed_produced numeric NOT NULL
);
ALTER TABLE stacks_blockchain_api.miner_rewards OWNER TO stacks;
--
-- Name: miner_rewards_id_seq; Type: SEQUENCE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE SEQUENCE stacks_blockchain_api.miner_rewards_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE stacks_blockchain_api.miner_rewards_id_seq OWNER TO stacks;
--
-- Name: miner_rewards_id_seq; Type: SEQUENCE OWNED BY; Schema: stacks_blockchain_api; Owner: stacks
--
ALTER SEQUENCE stacks_blockchain_api.miner_rewards_id_seq OWNED BY stacks_blockchain_api.miner_rewards.id;
--
-- Name: names; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.names (
id integer NOT NULL,
name text NOT NULL,
address text NOT NULL,
registered_at integer NOT NULL,
expire_block integer NOT NULL,
zonefile_hash text NOT NULL,
namespace_id text NOT NULL,
grace_period text,
renewal_deadline integer,
resolver text,
tx_id bytea,
tx_index smallint NOT NULL,
event_index integer,
status text,
canonical boolean DEFAULT true NOT NULL,
index_block_hash bytea,
parent_index_block_hash bytea NOT NULL,
microblock_hash bytea NOT NULL,
microblock_sequence integer NOT NULL,
microblock_canonical boolean NOT NULL
);
ALTER TABLE stacks_blockchain_api.names OWNER TO stacks;
--
-- Name: names_id_seq; Type: SEQUENCE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE SEQUENCE stacks_blockchain_api.names_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE stacks_blockchain_api.names_id_seq OWNER TO stacks;
--
-- Name: names_id_seq; Type: SEQUENCE OWNED BY; Schema: stacks_blockchain_api; Owner: stacks
--
ALTER SEQUENCE stacks_blockchain_api.names_id_seq OWNED BY stacks_blockchain_api.names.id;
--
-- Name: namespaces; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.namespaces (
id integer NOT NULL,
namespace_id text NOT NULL,
launched_at integer,
address text NOT NULL,
reveal_block integer NOT NULL,
ready_block integer NOT NULL,
buckets text NOT NULL,
base numeric NOT NULL,
coeff numeric NOT NULL,
nonalpha_discount numeric NOT NULL,
no_vowel_discount numeric NOT NULL,
lifetime integer NOT NULL,
status text,
tx_id bytea,
tx_index smallint NOT NULL,
canonical boolean DEFAULT true NOT NULL,
index_block_hash bytea,
parent_index_block_hash bytea NOT NULL,
microblock_hash bytea NOT NULL,
microblock_sequence integer NOT NULL,
microblock_canonical boolean NOT NULL
);
ALTER TABLE stacks_blockchain_api.namespaces OWNER TO stacks;
--
-- Name: namespaces_id_seq; Type: SEQUENCE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE SEQUENCE stacks_blockchain_api.namespaces_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE stacks_blockchain_api.namespaces_id_seq OWNER TO stacks;
--
-- Name: namespaces_id_seq; Type: SEQUENCE OWNED BY; Schema: stacks_blockchain_api; Owner: stacks
--
ALTER SEQUENCE stacks_blockchain_api.namespaces_id_seq OWNED BY stacks_blockchain_api.namespaces.id;
--
-- Name: nft_custody; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.nft_custody (
asset_identifier text NOT NULL,
value bytea NOT NULL,
recipient text,
block_height integer NOT NULL,
index_block_hash bytea NOT NULL,
parent_index_block_hash bytea NOT NULL,
microblock_hash bytea NOT NULL,
microblock_sequence integer NOT NULL,
tx_id bytea NOT NULL,
tx_index smallint NOT NULL,
event_index integer NOT NULL
);
ALTER TABLE stacks_blockchain_api.nft_custody OWNER TO stacks;
--
-- Name: nft_custody_unanchored; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.nft_custody_unanchored (
asset_identifier text NOT NULL,
value bytea NOT NULL,
recipient text,
block_height integer NOT NULL,
index_block_hash bytea NOT NULL,
parent_index_block_hash bytea NOT NULL,
microblock_hash bytea NOT NULL,
microblock_sequence integer NOT NULL,
tx_id bytea NOT NULL,
tx_index smallint NOT NULL,
event_index integer NOT NULL
);
ALTER TABLE stacks_blockchain_api.nft_custody_unanchored OWNER TO stacks;
--
-- Name: nft_events; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.nft_events (
id integer NOT NULL,
event_index integer NOT NULL,
tx_id bytea NOT NULL,
tx_index smallint NOT NULL,
block_height integer NOT NULL,
index_block_hash bytea NOT NULL,
parent_index_block_hash bytea NOT NULL,
microblock_hash bytea NOT NULL,
microblock_sequence integer NOT NULL,
microblock_canonical boolean NOT NULL,
canonical boolean NOT NULL,
asset_event_type_id smallint NOT NULL,
asset_identifier text NOT NULL,
value bytea NOT NULL,
sender text,
recipient text,
CONSTRAINT valid_asset_burn CHECK (((asset_event_type_id <> 3) OR ((recipient IS NULL) AND (sender IS NOT NULL)))),
CONSTRAINT valid_asset_mint CHECK (((asset_event_type_id <> 2) OR ((sender IS NULL) AND (recipient IS NOT NULL)))),
CONSTRAINT valid_asset_transfer CHECK (((asset_event_type_id <> 1) OR (NOT (ROW(sender, recipient) IS NULL))))
);
ALTER TABLE stacks_blockchain_api.nft_events OWNER TO stacks;
--
-- Name: nft_events_id_seq; Type: SEQUENCE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE SEQUENCE stacks_blockchain_api.nft_events_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE stacks_blockchain_api.nft_events_id_seq OWNER TO stacks;
--
-- Name: nft_events_id_seq; Type: SEQUENCE OWNED BY; Schema: stacks_blockchain_api; Owner: stacks
--
ALTER SEQUENCE stacks_blockchain_api.nft_events_id_seq OWNED BY stacks_blockchain_api.nft_events.id;
--
-- Name: pgmigrations; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.pgmigrations (
id integer NOT NULL,
name character varying(255) NOT NULL,
run_on timestamp without time zone NOT NULL
);
ALTER TABLE stacks_blockchain_api.pgmigrations OWNER TO stacks;
--
-- Name: pgmigrations_id_seq; Type: SEQUENCE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE SEQUENCE stacks_blockchain_api.pgmigrations_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE stacks_blockchain_api.pgmigrations_id_seq OWNER TO stacks;
--
-- Name: pgmigrations_id_seq; Type: SEQUENCE OWNED BY; Schema: stacks_blockchain_api; Owner: stacks
--
ALTER SEQUENCE stacks_blockchain_api.pgmigrations_id_seq OWNED BY stacks_blockchain_api.pgmigrations.id;
--
-- Name: pox2_events; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.pox2_events (
id bigint NOT NULL,
event_index integer NOT NULL,
tx_id bytea NOT NULL,
tx_index smallint NOT NULL,
block_height integer NOT NULL,
index_block_hash bytea NOT NULL,
parent_index_block_hash bytea NOT NULL,
microblock_hash bytea NOT NULL,
microblock_sequence integer NOT NULL,
microblock_canonical boolean NOT NULL,
canonical boolean NOT NULL,
stacker text NOT NULL,
locked numeric NOT NULL,
balance numeric NOT NULL,
burnchain_unlock_height bigint NOT NULL,
name text NOT NULL,
pox_addr text,
pox_addr_raw bytea,
first_cycle_locked numeric,
first_unlocked_cycle numeric,
delegate_to text,
lock_period numeric,
lock_amount numeric,
start_burn_height numeric,
unlock_burn_height numeric,
delegator text,
increase_by numeric,
total_locked numeric,
extend_count numeric,
reward_cycle numeric,
amount_ustx numeric,
CONSTRAINT valid_event_specific_columns CHECK (
CASE name
WHEN 'handle-unlock'::text THEN ((first_cycle_locked IS NOT NULL) AND (first_unlocked_cycle IS NOT NULL))
WHEN 'stack-stx'::text THEN ((lock_period IS NOT NULL) AND (lock_amount IS NOT NULL) AND (start_burn_height IS NOT NULL) AND (unlock_burn_height IS NOT NULL))
WHEN 'stack-increase'::text THEN ((increase_by IS NOT NULL) AND (total_locked IS NOT NULL))
WHEN 'stack-extend'::text THEN ((extend_count IS NOT NULL) AND (unlock_burn_height IS NOT NULL))
WHEN 'delegate-stx'::text THEN ((amount_ustx IS NOT NULL) AND (delegate_to IS NOT NULL))
WHEN 'delegate-stack-stx'::text THEN ((lock_period IS NOT NULL) AND (lock_amount IS NOT NULL) AND (start_burn_height IS NOT NULL) AND (unlock_burn_height IS NOT NULL) AND (delegator IS NOT NULL))
WHEN 'delegate-stack-increase'::text THEN ((increase_by IS NOT NULL) AND (total_locked IS NOT NULL) AND (delegator IS NOT NULL))
WHEN 'delegate-stack-extend'::text THEN ((extend_count IS NOT NULL) AND (unlock_burn_height IS NOT NULL) AND (delegator IS NOT NULL))
WHEN 'stack-aggregation-commit'::text THEN ((reward_cycle IS NOT NULL) AND (amount_ustx IS NOT NULL))
WHEN 'stack-aggregation-commit-indexed'::text THEN ((reward_cycle IS NOT NULL) AND (amount_ustx IS NOT NULL))
WHEN 'stack-aggregation-increase'::text THEN ((reward_cycle IS NOT NULL) AND (amount_ustx IS NOT NULL))
ELSE false
END)
);
ALTER TABLE stacks_blockchain_api.pox2_events OWNER TO stacks;
--
-- Name: pox2_events_id_seq; Type: SEQUENCE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE SEQUENCE stacks_blockchain_api.pox2_events_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE stacks_blockchain_api.pox2_events_id_seq OWNER TO stacks;
--
-- Name: pox2_events_id_seq; Type: SEQUENCE OWNED BY; Schema: stacks_blockchain_api; Owner: stacks
--
ALTER SEQUENCE stacks_blockchain_api.pox2_events_id_seq OWNED BY stacks_blockchain_api.pox2_events.id;
--
-- Name: pox3_events; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.pox3_events (
id bigint NOT NULL,
event_index integer NOT NULL,
tx_id bytea NOT NULL,
tx_index smallint NOT NULL,
block_height integer NOT NULL,
index_block_hash bytea NOT NULL,
parent_index_block_hash bytea NOT NULL,
microblock_hash bytea NOT NULL,
microblock_sequence integer NOT NULL,
microblock_canonical boolean NOT NULL,
canonical boolean NOT NULL,
stacker text NOT NULL,
locked numeric NOT NULL,
balance numeric NOT NULL,
burnchain_unlock_height bigint NOT NULL,
name text NOT NULL,
pox_addr text,
pox_addr_raw bytea,
first_cycle_locked numeric,
first_unlocked_cycle numeric,
delegate_to text,
lock_period numeric,
lock_amount numeric,
start_burn_height numeric,
unlock_burn_height numeric,
delegator text,
increase_by numeric,
total_locked numeric,
extend_count numeric,
reward_cycle numeric,
amount_ustx numeric,
CONSTRAINT valid_event_specific_columns CHECK (
CASE name
WHEN 'handle-unlock'::text THEN ((first_cycle_locked IS NOT NULL) AND (first_unlocked_cycle IS NOT NULL))
WHEN 'stack-stx'::text THEN ((lock_period IS NOT NULL) AND (lock_amount IS NOT NULL) AND (start_burn_height IS NOT NULL) AND (unlock_burn_height IS NOT NULL))
WHEN 'stack-increase'::text THEN ((increase_by IS NOT NULL) AND (total_locked IS NOT NULL))
WHEN 'stack-extend'::text THEN ((extend_count IS NOT NULL) AND (unlock_burn_height IS NOT NULL))
WHEN 'delegate-stx'::text THEN ((amount_ustx IS NOT NULL) AND (delegate_to IS NOT NULL))
WHEN 'delegate-stack-stx'::text THEN ((lock_period IS NOT NULL) AND (lock_amount IS NOT NULL) AND (start_burn_height IS NOT NULL) AND (unlock_burn_height IS NOT NULL) AND (delegator IS NOT NULL))
WHEN 'delegate-stack-increase'::text THEN ((increase_by IS NOT NULL) AND (total_locked IS NOT NULL) AND (delegator IS NOT NULL))
WHEN 'delegate-stack-extend'::text THEN ((extend_count IS NOT NULL) AND (unlock_burn_height IS NOT NULL) AND (delegator IS NOT NULL))
WHEN 'stack-aggregation-commit'::text THEN ((reward_cycle IS NOT NULL) AND (amount_ustx IS NOT NULL))
WHEN 'stack-aggregation-commit-indexed'::text THEN ((reward_cycle IS NOT NULL) AND (amount_ustx IS NOT NULL))
WHEN 'stack-aggregation-increase'::text THEN ((reward_cycle IS NOT NULL) AND (amount_ustx IS NOT NULL))
ELSE false
END)
);
ALTER TABLE stacks_blockchain_api.pox3_events OWNER TO stacks;
--
-- Name: pox3_events_id_seq; Type: SEQUENCE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE SEQUENCE stacks_blockchain_api.pox3_events_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE stacks_blockchain_api.pox3_events_id_seq OWNER TO stacks;
--
-- Name: pox3_events_id_seq; Type: SEQUENCE OWNED BY; Schema: stacks_blockchain_api; Owner: stacks
--
ALTER SEQUENCE stacks_blockchain_api.pox3_events_id_seq OWNED BY stacks_blockchain_api.pox3_events.id;
--
-- Name: pox4_events; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.pox4_events (
id bigint NOT NULL,
event_index integer NOT NULL,
tx_id bytea NOT NULL,
tx_index smallint NOT NULL,
block_height integer NOT NULL,
index_block_hash bytea NOT NULL,
parent_index_block_hash bytea NOT NULL,
microblock_hash bytea NOT NULL,
microblock_sequence integer NOT NULL,
microblock_canonical boolean NOT NULL,
canonical boolean NOT NULL,
stacker text NOT NULL,
locked numeric NOT NULL,
balance numeric NOT NULL,
burnchain_unlock_height bigint NOT NULL,
name text NOT NULL,
pox_addr text,
pox_addr_raw bytea,
first_cycle_locked numeric,
first_unlocked_cycle numeric,
delegate_to text,
lock_period numeric,
lock_amount numeric,
start_burn_height numeric,
unlock_burn_height numeric,
delegator text,
increase_by numeric,
total_locked numeric,
extend_count numeric,
reward_cycle numeric,
amount_ustx numeric,
CONSTRAINT valid_event_specific_columns CHECK (
CASE name
WHEN 'handle-unlock'::text THEN ((first_cycle_locked IS NOT NULL) AND (first_unlocked_cycle IS NOT NULL))
WHEN 'stack-stx'::text THEN ((lock_period IS NOT NULL) AND (lock_amount IS NOT NULL) AND (start_burn_height IS NOT NULL) AND (unlock_burn_height IS NOT NULL))
WHEN 'stack-increase'::text THEN ((increase_by IS NOT NULL) AND (total_locked IS NOT NULL))
WHEN 'stack-extend'::text THEN ((extend_count IS NOT NULL) AND (unlock_burn_height IS NOT NULL))
WHEN 'delegate-stx'::text THEN ((amount_ustx IS NOT NULL) AND (delegate_to IS NOT NULL))
WHEN 'delegate-stack-stx'::text THEN ((lock_period IS NOT NULL) AND (lock_amount IS NOT NULL) AND (start_burn_height IS NOT NULL) AND (unlock_burn_height IS NOT NULL) AND (delegator IS NOT NULL))
WHEN 'delegate-stack-increase'::text THEN ((increase_by IS NOT NULL) AND (total_locked IS NOT NULL) AND (delegator IS NOT NULL))
WHEN 'delegate-stack-extend'::text THEN ((extend_count IS NOT NULL) AND (unlock_burn_height IS NOT NULL) AND (delegator IS NOT NULL))
WHEN 'stack-aggregation-commit'::text THEN ((reward_cycle IS NOT NULL) AND (amount_ustx IS NOT NULL))
WHEN 'stack-aggregation-commit-indexed'::text THEN ((reward_cycle IS NOT NULL) AND (amount_ustx IS NOT NULL))
WHEN 'stack-aggregation-increase'::text THEN ((reward_cycle IS NOT NULL) AND (amount_ustx IS NOT NULL))
ELSE false
END)
);
ALTER TABLE stacks_blockchain_api.pox4_events OWNER TO stacks;
--
-- Name: pox4_events_id_seq; Type: SEQUENCE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE SEQUENCE stacks_blockchain_api.pox4_events_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE stacks_blockchain_api.pox4_events_id_seq OWNER TO stacks;
--
-- Name: pox4_events_id_seq; Type: SEQUENCE OWNED BY; Schema: stacks_blockchain_api; Owner: stacks
--
ALTER SEQUENCE stacks_blockchain_api.pox4_events_id_seq OWNED BY stacks_blockchain_api.pox4_events.id;
--
-- Name: pox_state; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.pox_state (
id boolean DEFAULT true NOT NULL,
pox_v1_unlock_height bigint DEFAULT 0 NOT NULL,
pox_v2_unlock_height bigint DEFAULT 0 NOT NULL,
pox_v3_unlock_height bigint DEFAULT 0 NOT NULL,
CONSTRAINT only_one_row CHECK (id)
);
ALTER TABLE stacks_blockchain_api.pox_state OWNER TO stacks;
--
-- Name: principal_stx_txs; Type: TABLE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE TABLE stacks_blockchain_api.principal_stx_txs (
id integer NOT NULL,
principal text NOT NULL,
tx_id bytea NOT NULL,
block_height integer NOT NULL,
index_block_hash bytea NOT NULL,
microblock_hash bytea NOT NULL,
microblock_sequence integer NOT NULL,
tx_index smallint NOT NULL,
canonical boolean NOT NULL,
microblock_canonical boolean NOT NULL
);
ALTER TABLE stacks_blockchain_api.principal_stx_txs OWNER TO stacks;
--
-- Name: principal_stx_txs_id_seq; Type: SEQUENCE; Schema: stacks_blockchain_api; Owner: stacks
--
CREATE SEQUENCE stacks_blockchain_api.principal_stx_txs_id_seq
AS integer
START WITH 1