-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdb_schema.sql
More file actions
12931 lines (9193 loc) · 375 KB
/
Copy pathdb_schema.sql
File metadata and controls
12931 lines (9193 loc) · 375 KB
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 14.13 (Ubuntu 14.13-0ubuntu0.22.04.1)
-- Dumped by pg_dump version 14.13 (Ubuntu 14.13-0ubuntu0.22.04.1)
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: atomic_schema; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA atomic_schema;
ALTER SCHEMA atomic_schema OWNER TO postgres;
--
-- Name: dbff_schema; Type: SCHEMA; Schema: -; Owner: postgres
--
CREATE SCHEMA dbff_schema;
ALTER SCHEMA dbff_schema OWNER TO postgres;
--
-- Name: intarray; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS intarray WITH SCHEMA public;
--
-- Name: EXTENSION intarray; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION intarray IS 'functions, operators, and index support for 1-D arrays of integers';
--
-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public;
--
-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION pg_stat_statements IS 'track planning and execution statistics of all SQL statements executed';
--
-- Name: pgstattuple; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS pgstattuple WITH SCHEMA public;
--
-- Name: EXTENSION pgstattuple; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION pgstattuple IS 'show tuple-level statistics';
--
-- Name: attribute; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.attribute AS (
name character varying(64),
type character varying(12)
);
ALTER TYPE public.attribute OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: account_value_actions; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.account_value_actions (
account character varying(13),
action_name character varying(13),
list_name character varying(13),
"values" character varying(13)[],
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone,
added boolean DEFAULT false
);
ALTER TABLE public.account_value_actions OWNER TO postgres;
--
-- Name: asset_mints; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.asset_mints (
asset_id bigint,
template_id integer,
mint integer
);
ALTER TABLE public.asset_mints OWNER TO postgres;
--
-- Name: assets; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.assets (
asset_id bigint NOT NULL,
contract character varying(12),
collection character varying(12),
schema character varying(16),
owner character varying(12),
template_id integer,
name_id integer,
image_id integer,
video_id integer,
block_num bigint,
seq bigint,
"timestamp" timestamp without time zone,
transferred timestamp without time zone,
burnable boolean,
transferable boolean,
attribute_ids integer[],
immutable_data_id integer,
mutable_data_id integer,
burned boolean DEFAULT false,
mint integer
);
ALTER TABLE public.assets OWNER TO postgres;
--
-- Name: atomicassets_burns; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicassets_burns (
asset_id bigint,
burner character varying(13),
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicassets_burns OWNER TO postgres;
--
-- Name: atomicassets_burns_reversed; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicassets_burns_reversed (
asset_id bigint,
burner character varying(13),
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicassets_burns_reversed OWNER TO postgres;
--
-- Name: atomicassets_offer_logs; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicassets_offer_logs (
offer_id bigint,
sender character varying(13),
recipient character varying(13),
sender_asset_ids bigint[],
recipient_asset_ids bigint[],
status character varying(12),
memo_id integer,
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicassets_offer_logs OWNER TO postgres;
--
-- Name: atomicassets_offer_updates; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicassets_offer_updates (
offer_id bigint,
status character varying(12),
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicassets_offer_updates OWNER TO postgres;
--
-- Name: atomicassets_offers; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicassets_offers (
offer_id bigint,
sender character varying(13),
recipient character varying(13),
sender_asset_ids bigint[],
recipient_asset_ids bigint[],
status character varying(13),
memo_id integer,
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicassets_offers OWNER TO postgres;
--
-- Name: atomicassets_updates; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicassets_updates (
asset_id bigint,
new_mdata_id integer,
old_mdata_id integer,
applied boolean DEFAULT false,
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicassets_updates OWNER TO postgres;
--
-- Name: atomicassets_updates_reversed; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicassets_updates_reversed (
asset_id bigint,
new_mdata_id integer,
old_mdata_id integer,
applied boolean,
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicassets_updates_reversed OWNER TO postgres;
--
-- Name: atomicmarket_accept_buy_offers; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicmarket_accept_buy_offers (
buyoffer_id bigint,
expected_asset_ids bigint[],
expected_price double precision,
taker_marketplace character varying(13),
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicmarket_accept_buy_offers OWNER TO postgres;
--
-- Name: atomicmarket_auction_cancels; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicmarket_auction_cancels (
auction_id bigint,
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicmarket_auction_cancels OWNER TO postgres;
--
-- Name: atomicmarket_buy_offers; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicmarket_buy_offers (
buyoffer_id bigint,
buyer character varying(13),
recipient character varying(13),
price double precision,
currency character varying(13),
asset_ids bigint[],
memo_id integer,
maker_marketplace character varying(13),
collection character varying(13),
collection_fee double precision,
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicmarket_buy_offers OWNER TO postgres;
--
-- Name: atomicmarket_buy_offers_listings; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicmarket_buy_offers_listings (
buyoffer_id bigint,
buyer character varying(13),
recipient character varying(13),
price double precision,
currency character varying(13),
asset_ids bigint[],
memo_id integer,
maker_marketplace character varying(13),
collection character varying(13),
collection_fee double precision,
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicmarket_buy_offers_listings OWNER TO postgres;
--
-- Name: atomicmarket_cancel_buy_offers; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicmarket_cancel_buy_offers (
buyoffer_id bigint,
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicmarket_cancel_buy_offers OWNER TO postgres;
--
-- Name: atomicmarket_cancel_template_buy_offers; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicmarket_cancel_template_buy_offers (
buyoffer_id bigint,
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicmarket_cancel_template_buy_offers OWNER TO postgres;
--
-- Name: atomicmarket_cancels; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicmarket_cancels (
block_num bigint,
seq bigint,
"timestamp" timestamp without time zone,
listing_id bigint
);
ALTER TABLE public.atomicmarket_cancels OWNER TO postgres;
--
-- Name: atomicmarket_decline_buy_offers; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicmarket_decline_buy_offers (
buyoffer_id bigint,
memo_id integer,
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicmarket_decline_buy_offers OWNER TO postgres;
--
-- Name: atomicmarket_fulfill_template_buy_offers; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicmarket_fulfill_template_buy_offers (
buyoffer_id bigint,
asset_id bigint,
seller character varying(13),
price double precision,
currency character varying(12),
taker character varying(13),
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicmarket_fulfill_template_buy_offers OWNER TO postgres;
--
-- Name: atomicmarket_listings; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicmarket_listings (
asset_ids bigint[],
seller character varying(13),
price double precision,
currency character varying(12),
listing_id bigint,
maker character varying(13),
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicmarket_listings OWNER TO postgres;
--
-- Name: atomicmarket_purchases; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicmarket_purchases (
buyer character varying(13),
block_num bigint,
seq bigint,
"timestamp" timestamp without time zone,
listing_id bigint,
taker character varying(13)
);
ALTER TABLE public.atomicmarket_purchases OWNER TO postgres;
--
-- Name: atomicmarket_sale_starts; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicmarket_sale_starts (
listing_id bigint,
offer_id bigint,
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicmarket_sale_starts OWNER TO postgres;
--
-- Name: atomicmarket_template_buy_offer_listings; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicmarket_template_buy_offer_listings (
buyoffer_id bigint NOT NULL,
buyer character varying(13),
price double precision,
currency character varying(12),
template_id bigint,
maker character varying(13),
collection character varying(13),
collection_fee double precision,
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicmarket_template_buy_offer_listings OWNER TO postgres;
--
-- Name: atomicmarket_template_buy_offers; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.atomicmarket_template_buy_offers (
buyoffer_id bigint NOT NULL,
buyer character varying(13),
price double precision,
currency character varying(12),
template_id bigint,
maker character varying(13),
collection character varying(13),
collection_fee double precision,
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.atomicmarket_template_buy_offers OWNER TO postgres;
--
-- Name: attributes; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.attributes (
attribute_id integer NOT NULL,
collection character varying(13),
schema character varying(16),
attribute_name character varying(64),
string_value character varying(256),
int_value bigint,
float_value double precision,
bool_value boolean
);
ALTER TABLE public.attributes OWNER TO postgres;
--
-- Name: listings; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.listings (
asset_ids bigint[],
collection character varying(13),
seller character varying(13),
market character varying(13),
maker character varying(13),
price double precision,
currency character varying(12),
listing_id bigint,
sale_id bigint NOT NULL,
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone,
estimated_wax_price double precision
);
ALTER TABLE public.listings OWNER TO postgres;
--
-- Name: usd_prices; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.usd_prices (
"timestamp" timestamp without time zone,
usd double precision
);
ALTER TABLE public.usd_prices OWNER TO postgres;
--
-- Name: attribute_floors_mv; Type: MATERIALIZED VIEW; Schema: public; Owner: postgres
--
CREATE MATERIALIZED VIEW public.attribute_floors_mv AS
SELECT att.attribute_id,
min(
CASE
WHEN ((s.currency)::text = 'WAX'::text) THEN s.price
ELSE (s.price / ( SELECT usd_prices.usd
FROM public.usd_prices
ORDER BY usd_prices."timestamp" DESC
LIMIT 1))
END) AS floor_wax,
min(
CASE
WHEN ((s.currency)::text = 'USD'::text) THEN s.price
ELSE (s.price * ( SELECT usd_prices.usd
FROM public.usd_prices
ORDER BY usd_prices."timestamp" DESC
LIMIT 1))
END) AS floor_usd
FROM ((public.listings s
JOIN public.assets a ON ((a.asset_id = ANY (s.asset_ids))))
JOIN public.attributes att ON ((att.attribute_id = ANY (a.attribute_ids))))
GROUP BY att.attribute_id
WITH NO DATA;
ALTER TABLE public.attribute_floors_mv OWNER TO postgres;
--
-- Name: attribute_stats; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.attribute_stats (
collection character varying(13),
schema character varying(13),
attribute_id integer,
total integer,
avg_wax_price double precision,
avg_usd_price double precision,
last_sold_wax double precision,
last_sold_usd double precision,
last_sold_seq bigint,
last_sold_block_num bigint,
floor_wax double precision,
floor_usd double precision,
volume_wax double precision,
volume_usd double precision,
num_sales integer,
total_schema integer,
rarity_score double precision
);
ALTER TABLE public.attribute_stats OWNER TO postgres;
--
-- Name: attributes_attribute_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE public.attributes_attribute_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE public.attributes_attribute_id_seq OWNER TO postgres;
--
-- Name: attributes_attribute_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE public.attributes_attribute_id_seq OWNED BY public.attributes.attribute_id;
--
-- Name: auction_bids; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.auction_bids (
bidder character varying(13),
bid double precision,
currency character varying(12),
auction_id bigint,
taker character varying(13),
market character varying(13),
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.auction_bids OWNER TO postgres;
--
-- Name: auction_claims; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.auction_claims (
auction_id bigint,
market character varying(13),
claimer character varying(13),
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.auction_claims OWNER TO postgres;
--
-- Name: auction_logs; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.auction_logs (
auction_id bigint,
asset_ids bigint[],
seller character varying(13),
end_time timestamp without time zone,
start_bid double precision,
current_bid double precision,
currency character varying(12),
maker character varying(13),
market character varying(13),
active boolean,
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.auction_logs OWNER TO postgres;
--
-- Name: auctions; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.auctions (
auction_id bigint,
asset_ids bigint[],
seller character varying(13),
end_time timestamp without time zone,
start_bid double precision,
current_bid double precision,
currency character varying(12),
maker character varying(13),
market character varying(13),
active boolean,
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.auctions OWNER TO postgres;
--
-- Name: backed_assets; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.backed_assets (
asset_id bigint,
amount double precision,
currency character varying(12),
backer character varying(13),
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.backed_assets OWNER TO postgres;
--
-- Name: badges; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.badges (
collection character varying(13),
name character varying(32),
level integer,
value character varying(32),
"timestamp" timestamp without time zone
);
ALTER TABLE public.badges OWNER TO postgres;
--
-- Name: banners; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.banners (
image character varying(256),
url character varying(256),
start_date timestamp without time zone,
end_date timestamp without time zone,
source character varying(12),
seq bigint,
block_num bigint,
"timestamp" timestamp without time zone
);
ALTER TABLE public.banners OWNER TO postgres;
--
-- Name: blacklisted_collections; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.blacklisted_collections (
collection character varying(13)
);
ALTER TABLE public.blacklisted_collections OWNER TO postgres;
--
-- Name: indexes; Type: VIEW; Schema: public; Owner: postgres
--
CREATE VIEW public.indexes AS
SELECT t.relname AS table_name,
i.relname AS index_name,
a.attname AS column_name
FROM pg_class t,
pg_class i,
pg_index ix,
pg_attribute a
WHERE ((t.oid = ix.indrelid) AND (i.oid = ix.indexrelid) AND (a.attrelid = t.oid) AND (a.attnum = ANY ((ix.indkey)::smallint[])) AND (t.relkind = 'r'::"char"))
ORDER BY t.relname, i.relname;
ALTER TABLE public.indexes OWNER TO postgres;
--
-- Name: tables_with_block_num; Type: VIEW; Schema: public; Owner: postgres
--
CREATE VIEW public.tables_with_block_num AS
SELECT t.table_schema,
t.table_name
FROM (information_schema.tables t
JOIN information_schema.columns c ON ((((c.table_name)::name = (t.table_name)::name) AND ((c.table_schema)::name = (t.table_schema)::name))))
WHERE (((c.column_name)::name = 'block_num'::name) AND ((t.table_schema)::name <> ALL (ARRAY['information_schema'::name, 'pg_catalog'::name])) AND ((t.table_type)::text = 'BASE TABLE'::text))
ORDER BY t.table_schema;
ALTER TABLE public.tables_with_block_num OWNER TO postgres;
--
-- Name: block_num_index_creation; Type: VIEW; Schema: public; Owner: postgres
--
CREATE VIEW public.block_num_index_creation AS
SELECT ((' CREATE INDEX ON '::text || (f.table_name)::text) || ' (block_num ASC) ;'::text) AS "?column?"
FROM ( SELECT tables_with_block_num.table_name
FROM public.tables_with_block_num
WHERE (NOT ((tables_with_block_num.table_name)::name IN ( SELECT indexes.table_name
FROM public.indexes
WHERE (indexes.column_name = 'block_num'::name))))) f;
ALTER TABLE public.block_num_index_creation OWNER TO postgres;
--
-- Name: blocked_queries; Type: VIEW; Schema: public; Owner: postgres
--
CREATE VIEW public.blocked_queries AS
SELECT pg_stat_activity.pid,
pg_stat_activity.usename,
pg_blocking_pids(pg_stat_activity.pid) AS blocked_by,
pg_stat_activity.query AS blocked_query
FROM pg_stat_activity
WHERE (cardinality(pg_blocking_pids(pg_stat_activity.pid)) > 0);
ALTER TABLE public.blocked_queries OWNER TO postgres;
--
-- Name: sales_summary; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.sales_summary (
collection character varying(13),
type character varying(10),
wax_price double precision,
usd_price double precision,
num_items integer,
buyer character varying(13),
seller character varying(13),
market character varying(13),
taker character varying(13),
maker character varying(13),
listing_id bigint,
"timestamp" timestamp without time zone,
seq bigint,
block_num bigint
);
ALTER TABLE public.sales_summary OWNER TO postgres;
--
-- Name: buyer_volumes_mv; Type: MATERIALIZED VIEW; Schema: public; Owner: postgres
--
CREATE MATERIALIZED VIEW public.buyer_volumes_mv AS
SELECT sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '1 day'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.wax_price
ELSE (0)::double precision
END) AS wax_volume_1_day,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '1 day'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.usd_price
ELSE (0)::double precision
END) AS usd_volume_1_day,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '2 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.wax_price
ELSE (0)::double precision
END) AS wax_volume_2_days,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '2 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.usd_price
ELSE (0)::double precision
END) AS usd_volume_2_days,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '3 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.wax_price
ELSE (0)::double precision
END) AS wax_volume_3_days,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '3 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.usd_price
ELSE (0)::double precision
END) AS usd_volume_3_days,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '7 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.wax_price
ELSE (0)::double precision
END) AS wax_volume_7_days,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '7 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.usd_price
ELSE (0)::double precision
END) AS usd_volume_7_days,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '14 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.wax_price
ELSE (0)::double precision
END) AS wax_volume_14_days,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '14 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.usd_price
ELSE (0)::double precision
END) AS usd_volume_14_days,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '30 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.wax_price
ELSE (0)::double precision
END) AS wax_volume_30_days,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '30 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.usd_price
ELSE (0)::double precision
END) AS usd_volume_30_days,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '60 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.wax_price
ELSE (0)::double precision
END) AS wax_volume_60_days,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '60 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.usd_price
ELSE (0)::double precision
END) AS usd_volume_60_days,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '90 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.wax_price
ELSE (0)::double precision
END) AS wax_volume_90_days,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '90 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.usd_price
ELSE (0)::double precision
END) AS usd_volume_90_days,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '180 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.wax_price
ELSE (0)::double precision
END) AS wax_volume_180_days,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '180 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.usd_price
ELSE (0)::double precision
END) AS usd_volume_180_days,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '365 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.wax_price
ELSE (0)::double precision
END) AS wax_volume_365_days,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '365 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.usd_price
ELSE (0)::double precision
END) AS usd_volume_365_days,
sum(sales_summary.wax_price) AS wax_volume_all_time,
sum(sales_summary.usd_price) AS usd_volume_all_time,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '1 day'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.num_items
ELSE 0
END) AS purchases_1_day,
sum(
CASE
WHEN (sales_summary."timestamp" > ((now() - '2 days'::interval) AT TIME ZONE 'utc'::text)) THEN sales_summary.num_items
ELSE 0
END) AS purchases_2_days,
sum(
CASE