Repository navigation
Expand file tree
/
Copy pathsetup.sql
More file actions
1703 lines (1323 loc) · 59.6 KB
/
Copy pathsetup.sql
File metadata and controls
1703 lines (1323 loc) · 59.6 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
--
-- Arkham Horror LCG schema.
--
-- GENERATED FILE -- do not edit by hand.
-- Produced by scripts/gen-setup-sql.sh, which replays migrations/deploy/*.sql
-- in sqitch.plan order into a throwaway database and dumps the result. To
-- change the schema, add a migration and run `make setup-sql`.
--
--
--
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: uuid-ossp; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;
--
-- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)';
--
-- Name: check_no_higher_step_exists(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.check_no_higher_step_exists() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
IF coalesce(current_setting('arkham.archiving', true), '') = 'on' THEN
RETURN OLD;
END IF;
-- Check if the game still exists
IF EXISTS (
SELECT 1
FROM arkham_games
WHERE id = OLD.arkham_game_id
) THEN
-- If the game exists, check if there is any step with a higher step number for the same game
IF EXISTS (
SELECT 1
FROM arkham_steps
WHERE arkham_game_id = OLD.arkham_game_id
AND step > OLD.step
) THEN
RAISE EXCEPTION 'Cannot delete step % because a higher step exists for the same game.', OLD.step;
END IF;
END IF;
RETURN OLD;
END;
$$;
--
-- Name: check_step_before_delete(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.check_step_before_delete() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
IF coalesce(current_setting('arkham.archiving', true), '') = 'on' THEN
RETURN OLD;
END IF;
-- Raise an exception if trying to delete a step that is equal to or less than the current step in the game
IF OLD.step <= (
SELECT step
FROM arkham_games
WHERE id = OLD.arkham_game_id
) THEN
RAISE EXCEPTION 'Cannot delete step % because it is equal to or less than the current step in the corresponding game.', OLD.step;
END IF;
RETURN OLD;
END;
$$;
--
-- Name: enforce_step_order_per_game(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.enforce_step_order_per_game() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
IF coalesce(current_setting('arkham.archiving', true), '') = 'on' THEN
RETURN NEW;
END IF;
-- Step 0 always starts a chain.
IF NEW.step = 0 THEN
RETURN NEW;
END IF;
-- Normal case: the immediately preceding step exists.
IF EXISTS (
SELECT 1 FROM arkham_steps
WHERE arkham_game_id = NEW.arkham_game_id
AND step = NEW.step - 1
) THEN
RETURN NEW;
END IF;
-- Recovery case: the game has no recorded steps at all (its undo history
-- was pruned or never persisted). Allow this insert to start a fresh
-- contiguous chain from the game's current step instead of wedging the
-- game so no action can ever be taken again.
IF NOT EXISTS (
SELECT 1 FROM arkham_steps
WHERE arkham_game_id = NEW.arkham_game_id
) THEN
RETURN NEW;
END IF;
RAISE EXCEPTION 'Cannot insert step % for game % without step %', NEW.step, NEW.arkham_game_id, NEW.step - 1;
END;
$$;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: arkham_achievements; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_achievements (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id bigint NOT NULL,
achievement character varying NOT NULL,
earned_at timestamp with time zone,
arkham_game_id uuid,
progress jsonb NOT NULL
);
--
-- Name: arkham_api_keys; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_api_keys (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id bigint NOT NULL,
name character varying NOT NULL,
prefix character varying NOT NULL,
digest character varying NOT NULL,
scopes character varying DEFAULT ''::character varying NOT NULL,
last_used_at timestamp with time zone,
expires_at timestamp with time zone,
revoked_at timestamp with time zone,
usage_window_start timestamp with time zone,
usage_count integer DEFAULT 0 NOT NULL,
created_at timestamp with time zone NOT NULL
);
--
-- Name: arkham_build_auth_requests; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_build_auth_requests (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id bigint NOT NULL,
redirect_uri character varying NOT NULL,
scopes character varying NOT NULL,
return_to character varying NOT NULL,
created_at timestamp with time zone NOT NULL
);
--
-- Name: arkham_build_connections; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_build_connections (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id bigint NOT NULL,
account_id character varying NOT NULL,
username character varying NOT NULL,
scopes character varying DEFAULT ''::character varying NOT NULL,
access_token character varying NOT NULL,
access_token_expires_at timestamp with time zone NOT NULL,
refresh_token character varying NOT NULL,
refresh_token_expires_at timestamp with time zone NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL
);
--
-- Name: arkham_card_set_share_accesses; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_card_set_share_accesses (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
card_set_share_id uuid NOT NULL,
user_id bigint NOT NULL,
custom_card_set_id uuid,
subscribed boolean DEFAULT true NOT NULL,
taken_at timestamp with time zone,
revoked_at timestamp with time zone,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL
);
--
-- Name: arkham_card_set_shares; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_card_set_shares (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
custom_card_set_id uuid NOT NULL,
token character varying NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL
);
--
-- Name: arkham_card_set_submissions; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_card_set_submissions (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
published_card_set_id uuid NOT NULL,
version_id uuid NOT NULL,
user_id bigint NOT NULL,
version integer NOT NULL,
status character varying DEFAULT 'pending'::character varying NOT NULL,
notify boolean DEFAULT true NOT NULL,
reason character varying,
reviewed_by_user_id bigint,
reviewed_at timestamp with time zone,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL
);
--
-- Name: arkham_card_set_subscriptions; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_card_set_subscriptions (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
custom_card_set_id uuid NOT NULL,
published_card_set_id uuid NOT NULL,
version integer NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
subscribed boolean DEFAULT true NOT NULL
);
--
-- Name: arkham_custom_card_sets; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_custom_card_sets (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id bigint NOT NULL,
name character varying NOT NULL,
source_code character varying,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
description text,
url text,
investigator_expansion boolean DEFAULT false NOT NULL,
icon text,
tokens jsonb DEFAULT '[]'::jsonb NOT NULL,
keywords jsonb DEFAULT '[]'::jsonb NOT NULL
);
--
-- Name: arkham_custom_cards; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_custom_cards (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id bigint NOT NULL,
card_code character varying NOT NULL,
def jsonb NOT NULL,
art text,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
custom_card_set_id uuid NOT NULL
);
--
-- Name: arkham_decks; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_decks (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id bigint NOT NULL,
name text NOT NULL,
investigator_name text NOT NULL,
list jsonb NOT NULL,
url text,
"overlay" jsonb,
last_used_at timestamp with time zone
);
--
-- Name: arkham_decks_user_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.arkham_decks_user_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: arkham_decks_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.arkham_decks_user_id_seq OWNED BY public.arkham_decks.user_id;
--
-- Name: arkham_epic_events; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_epic_events (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
name text NOT NULL,
organizer_user_id bigint NOT NULL,
scenario_id text,
campaign_id text,
difficulty text NOT NULL,
shared_state jsonb NOT NULL,
total_investigators integer NOT NULL,
step integer NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL
);
--
-- Name: arkham_epic_groups; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_epic_groups (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
arkham_epic_event_id uuid NOT NULL,
ordinal integer NOT NULL,
arkham_game_id uuid,
name text NOT NULL,
seat_count integer NOT NULL
);
--
-- Name: arkham_epic_members; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_epic_members (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
arkham_epic_event_id uuid NOT NULL,
user_id bigint NOT NULL,
role text NOT NULL,
group_ordinal integer
);
--
-- Name: arkham_epic_steps; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_epic_steps (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
arkham_epic_event_id uuid NOT NULL,
step integer NOT NULL,
arkham_game_id uuid,
game_step integer,
delta jsonb NOT NULL,
created_at timestamp with time zone NOT NULL
);
--
-- Name: arkham_game_archives; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_game_archives (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
arkham_game_id uuid NOT NULL,
state text NOT NULL,
bucket text NOT NULL,
object_key text NOT NULL,
steps integer NOT NULL,
top_step integer NOT NULL,
bytes bigint NOT NULL,
archived_at timestamp with time zone NOT NULL,
game_updated_at timestamp with time zone NOT NULL,
requested_at timestamp with time zone,
requested_by bigint,
restored_at timestamp with time zone,
error_message text
);
--
-- Name: arkham_game_outcomes; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_game_outcomes (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
arkham_game_id uuid NOT NULL,
result text NOT NULL,
certainty text DEFAULT 'Certain'::text NOT NULL,
note text,
source text NOT NULL,
scenario_id text,
resolution_tag text,
resolution integer,
computed_at timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT valid_game_outcome_certainty CHECK ((certainty = ANY (ARRAY['Certain'::text, 'Uncertain'::text]))),
CONSTRAINT valid_game_outcome_result CHECK ((result = ANY (ARRAY['Won'::text, 'Lost'::text])))
);
--
-- Name: arkham_games; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_games (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
name text NOT NULL,
current_data jsonb NOT NULL,
multiplayer_variant text NOT NULL,
created_at timestamp without time zone DEFAULT now(),
updated_at timestamp without time zone DEFAULT now(),
step integer,
allow_spectators boolean DEFAULT false NOT NULL
);
--
-- Name: arkham_game_stats; Type: MATERIALIZED VIEW; Schema: public; Owner: -
--
CREATE MATERIALIZED VIEW public.arkham_game_stats AS
SELECT g.id AS game_id,
g.created_at,
g.updated_at,
g.multiplayer_variant,
((g.current_data -> 'gameMode'::text) ? 'This'::text) AS is_campaign,
(g.current_data #>> '{gameMode,This,id}'::text[]) AS campaign_id,
CASE
WHEN ((g.current_data #>> '{gameMode,That,id}'::text[]) ~~ 'c%'::text) THEN substr((g.current_data #>> '{gameMode,That,id}'::text[]), 2)
ELSE (g.current_data #>> '{gameMode,That,id}'::text[])
END AS scenario_id,
COALESCE((g.current_data #>> '{gameMode,This,difficulty}'::text[]), (g.current_data #>> '{gameMode,That,difficulty}'::text[])) AS difficulty,
(g.current_data #>> '{gameGameState,tag}'::text[]) AS state,
CASE
WHEN (jsonb_typeof((g.current_data -> 'gamePlayerCount'::text)) = 'number'::text) THEN ((g.current_data ->> 'gamePlayerCount'::text))::integer
ELSE NULL::integer
END AS player_count,
COALESCE((g.current_data #>> '{gameOutcome,result}'::text[]), o.result) AS outcome_result,
COALESCE((g.current_data #>> '{gameOutcome,certainty}'::text[]), o.certainty, 'Certain'::text) AS outcome_certainty,
COALESCE((g.current_data #>> '{gameOutcome,note}'::text[]), o.note) AS outcome_note,
COALESCE((g.current_data #>> '{gameOutcome,source}'::text[]), o.source) AS outcome_source,
CASE
WHEN (COALESCE((g.current_data #>> '{gameOutcome,ending,scenario}'::text[]), o.scenario_id) ~~ 'c%'::text) THEN substr(COALESCE((g.current_data #>> '{gameOutcome,ending,scenario}'::text[]), o.scenario_id), 2)
ELSE COALESCE((g.current_data #>> '{gameOutcome,ending,scenario}'::text[]), o.scenario_id)
END AS outcome_scenario,
COALESCE((g.current_data #>> '{gameOutcome,ending,resolution,tag}'::text[]), o.resolution_tag) AS outcome_resolution_tag,
COALESCE(
CASE
WHEN (jsonb_typeof((g.current_data #> '{gameOutcome,ending,resolution,contents}'::text[])) = 'number'::text) THEN ((g.current_data #>> '{gameOutcome,ending,resolution,contents}'::text[]))::integer
ELSE NULL::integer
END, o.resolution) AS outcome_resolution,
COALESCE(r.completed, '{}'::text[]) AS completed_scenarios,
COALESCE(r.resolved, '{}'::text[]) AS resolved_scenarios
FROM ((public.arkham_games g
LEFT JOIN LATERAL ( SELECT array_agg(
CASE
WHEN (e.key ~~ 'c%'::text) THEN substr(e.key, 2)
ELSE e.key
END ORDER BY e.key) AS completed,
array_agg(
CASE
WHEN (e.key ~~ 'c%'::text) THEN substr(e.key, 2)
ELSE e.key
END ORDER BY e.key) FILTER (WHERE ((e.value ->> 'tag'::text) = 'Resolution'::text)) AS resolved
FROM jsonb_each(
CASE
WHEN (jsonb_typeof((g.current_data #> '{gameMode,This,resolutions}'::text[])) = 'object'::text) THEN (g.current_data #> '{gameMode,This,resolutions}'::text[])
ELSE '{}'::jsonb
END) e(key, value)) r ON (true))
LEFT JOIN public.arkham_game_outcomes o ON ((o.arkham_game_id = g.id)))
WITH NO DATA;
--
-- Name: arkham_game_undo_floors; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_game_undo_floors (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
arkham_game_id uuid NOT NULL,
floor_step bigint NOT NULL
);
--
-- Name: arkham_log_entries; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_log_entries (
id bigint NOT NULL,
body text NOT NULL,
arkham_game_id uuid NOT NULL,
step integer NOT NULL,
created_at timestamp without time zone DEFAULT now(),
payload jsonb,
seq integer,
group_id text
);
--
-- Name: arkham_log_entries_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.arkham_log_entries_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: arkham_log_entries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.arkham_log_entries_id_seq OWNED BY public.arkham_log_entries.id;
--
-- Name: arkham_players; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_players (
arkham_game_id uuid NOT NULL,
user_id bigint NOT NULL,
investigator_id text NOT NULL,
id uuid DEFAULT public.uuid_generate_v4()
);
--
-- Name: arkham_players_user_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.arkham_players_user_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: arkham_players_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.arkham_players_user_id_seq OWNED BY public.arkham_players.user_id;
--
-- Name: arkham_published_card_set_likes; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_published_card_set_likes (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
published_card_set_id uuid NOT NULL,
user_id bigint NOT NULL,
created_at timestamp with time zone NOT NULL
);
--
-- Name: arkham_published_card_set_versions; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_published_card_set_versions (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
published_card_set_id uuid NOT NULL,
version integer NOT NULL,
note character varying,
name character varying NOT NULL,
cards jsonb NOT NULL,
created_at timestamp with time zone NOT NULL
);
--
-- Name: arkham_published_card_sets; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_published_card_sets (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id bigint NOT NULL,
custom_card_set_id uuid,
name character varying NOT NULL,
latest_version integer NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL,
approved_version integer,
description text,
url text,
investigator_expansion boolean DEFAULT false NOT NULL,
icon text
);
--
-- Name: arkham_stats_refreshes; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_stats_refreshes (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
name character varying NOT NULL,
refreshed_at timestamp with time zone NOT NULL,
duration_ms integer NOT NULL
);
--
-- Name: arkham_steps; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_steps (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
arkham_game_id uuid NOT NULL,
choice jsonb NOT NULL,
step integer NOT NULL,
action_diff jsonb NOT NULL
);
--
-- Name: arkham_third_edition_history; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_third_edition_history (
id bigint NOT NULL,
table_id uuid NOT NULL,
game jsonb NOT NULL,
created_at timestamp with time zone NOT NULL
);
--
-- Name: arkham_third_edition_history_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.arkham_third_edition_history_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: arkham_third_edition_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.arkham_third_edition_history_id_seq OWNED BY public.arkham_third_edition_history.id;
--
-- Name: arkham_third_edition_tables; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.arkham_third_edition_tables (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
host_id bigint NOT NULL,
started boolean NOT NULL,
version integer NOT NULL,
payload jsonb NOT NULL,
created_at timestamp with time zone NOT NULL,
updated_at timestamp with time zone NOT NULL
);
--
-- Name: notifications; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.notifications (
id integer NOT NULL,
body text,
created_at timestamp without time zone
);
--
-- Name: notifications_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.notifications_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: notifications_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.notifications_id_seq OWNED BY public.notifications.id;
--
-- Name: password_resets; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.password_resets (
id uuid DEFAULT public.uuid_generate_v1mc() NOT NULL,
user_id bigint NOT NULL,
expires_at timestamp with time zone NOT NULL
);
--
-- Name: password_resets_user_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.password_resets_user_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: password_resets_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.password_resets_user_id_seq OWNED BY public.password_resets.user_id;
--
-- Name: users; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.users (
id bigint NOT NULL,
username character varying NOT NULL,
email character varying NOT NULL,
password_digest character varying NOT NULL,
beta boolean DEFAULT false NOT NULL,
phase_transition_notifications boolean DEFAULT false NOT NULL,
features text DEFAULT ''::text NOT NULL,
allow_spectators_by_default boolean DEFAULT false NOT NULL,
admin boolean DEFAULT false
);
--
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.users_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.users_id_seq OWNED BY public.users.id;
--
-- Name: arkham_decks user_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_decks ALTER COLUMN user_id SET DEFAULT nextval('public.arkham_decks_user_id_seq'::regclass);
--
-- Name: arkham_log_entries id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_log_entries ALTER COLUMN id SET DEFAULT nextval('public.arkham_log_entries_id_seq'::regclass);
--
-- Name: arkham_players user_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_players ALTER COLUMN user_id SET DEFAULT nextval('public.arkham_players_user_id_seq'::regclass);
--
-- Name: arkham_third_edition_history id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_third_edition_history ALTER COLUMN id SET DEFAULT nextval('public.arkham_third_edition_history_id_seq'::regclass);
--
-- Name: notifications id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.notifications ALTER COLUMN id SET DEFAULT nextval('public.notifications_id_seq'::regclass);
--
-- Name: password_resets user_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.password_resets ALTER COLUMN user_id SET DEFAULT nextval('public.password_resets_user_id_seq'::regclass);
--
-- Name: users id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users ALTER COLUMN id SET DEFAULT nextval('public.users_id_seq'::regclass);
--
-- Name: arkham_achievements arkham_achievements_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_achievements
ADD CONSTRAINT arkham_achievements_pkey PRIMARY KEY (id);
--
-- Name: arkham_api_keys arkham_api_keys_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_api_keys
ADD CONSTRAINT arkham_api_keys_pkey PRIMARY KEY (id);
--
-- Name: arkham_build_auth_requests arkham_build_auth_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_build_auth_requests
ADD CONSTRAINT arkham_build_auth_requests_pkey PRIMARY KEY (id);
--
-- Name: arkham_build_connections arkham_build_connections_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_build_connections
ADD CONSTRAINT arkham_build_connections_pkey PRIMARY KEY (id);
--
-- Name: arkham_card_set_share_accesses arkham_card_set_share_accesses_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_card_set_share_accesses
ADD CONSTRAINT arkham_card_set_share_accesses_pkey PRIMARY KEY (id);
--
-- Name: arkham_card_set_shares arkham_card_set_shares_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_card_set_shares
ADD CONSTRAINT arkham_card_set_shares_pkey PRIMARY KEY (id);
--
-- Name: arkham_card_set_submissions arkham_card_set_submissions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_card_set_submissions
ADD CONSTRAINT arkham_card_set_submissions_pkey PRIMARY KEY (id);
--
-- Name: arkham_card_set_subscriptions arkham_card_set_subscriptions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_card_set_subscriptions
ADD CONSTRAINT arkham_card_set_subscriptions_pkey PRIMARY KEY (id);
--
-- Name: arkham_custom_card_sets arkham_custom_card_sets_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_custom_card_sets
ADD CONSTRAINT arkham_custom_card_sets_pkey PRIMARY KEY (id);
--
-- Name: arkham_custom_cards arkham_custom_cards_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_custom_cards
ADD CONSTRAINT arkham_custom_cards_pkey PRIMARY KEY (id);
--
-- Name: arkham_decks arkham_decks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_decks
ADD CONSTRAINT arkham_decks_pkey PRIMARY KEY (id);
--
-- Name: arkham_epic_events arkham_epic_events_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_epic_events
ADD CONSTRAINT arkham_epic_events_pkey PRIMARY KEY (id);
--
-- Name: arkham_epic_groups arkham_epic_groups_arkham_epic_event_id_ordinal_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_epic_groups
ADD CONSTRAINT arkham_epic_groups_arkham_epic_event_id_ordinal_key UNIQUE (arkham_epic_event_id, ordinal);
--
-- Name: arkham_epic_groups arkham_epic_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_epic_groups
ADD CONSTRAINT arkham_epic_groups_pkey PRIMARY KEY (id);
--
-- Name: arkham_epic_members arkham_epic_members_arkham_epic_event_id_user_id_role_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_epic_members
ADD CONSTRAINT arkham_epic_members_arkham_epic_event_id_user_id_role_key UNIQUE (arkham_epic_event_id, user_id, role);
--
-- Name: arkham_epic_members arkham_epic_members_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_epic_members
ADD CONSTRAINT arkham_epic_members_pkey PRIMARY KEY (id);
--
-- Name: arkham_epic_steps arkham_epic_steps_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_epic_steps
ADD CONSTRAINT arkham_epic_steps_pkey PRIMARY KEY (id);
--
-- Name: arkham_game_archives arkham_game_archives_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_game_archives
ADD CONSTRAINT arkham_game_archives_pkey PRIMARY KEY (id);
--
-- Name: arkham_game_outcomes arkham_game_outcomes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_game_outcomes
ADD CONSTRAINT arkham_game_outcomes_pkey PRIMARY KEY (id);
--
-- Name: arkham_game_undo_floors arkham_game_undo_floors_arkham_game_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_game_undo_floors
ADD CONSTRAINT arkham_game_undo_floors_arkham_game_id_key UNIQUE (arkham_game_id);
--
-- Name: arkham_game_undo_floors arkham_game_undo_floors_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_game_undo_floors
ADD CONSTRAINT arkham_game_undo_floors_pkey PRIMARY KEY (id);
--
-- Name: arkham_games arkham_games_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_games
ADD CONSTRAINT arkham_games_pkey PRIMARY KEY (id);
--
-- Name: arkham_log_entries arkham_log_entries_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_log_entries
ADD CONSTRAINT arkham_log_entries_pkey PRIMARY KEY (id);
--
-- Name: arkham_published_card_set_likes arkham_published_card_set_likes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_published_card_set_likes
ADD CONSTRAINT arkham_published_card_set_likes_pkey PRIMARY KEY (id);
--
-- Name: arkham_published_card_set_versions arkham_published_card_set_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_published_card_set_versions
ADD CONSTRAINT arkham_published_card_set_versions_pkey PRIMARY KEY (id);
--
-- Name: arkham_published_card_sets arkham_published_card_sets_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_published_card_sets
ADD CONSTRAINT arkham_published_card_sets_pkey PRIMARY KEY (id);
--
-- Name: arkham_stats_refreshes arkham_stats_refreshes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_stats_refreshes
ADD CONSTRAINT arkham_stats_refreshes_pkey PRIMARY KEY (id);
--
-- Name: arkham_steps arkham_steps_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.arkham_steps
ADD CONSTRAINT arkham_steps_pkey PRIMARY KEY (id);