-
Notifications
You must be signed in to change notification settings - Fork 87
/
structure.sql
1105 lines (748 loc) · 29.7 KB
/
structure.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 16.4 (Ubuntu 16.4-0ubuntu0.24.04.2)
-- Dumped by pg_dump version 16.4 (Ubuntu 16.4-0ubuntu0.24.04.2)
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: SCHEMA public; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON SCHEMA public IS 'Main schema';
--
-- Name: citext; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS citext WITH SCHEMA public;
--
-- Name: EXTENSION citext; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION citext IS 'data type for case-insensitive character strings';
--
-- 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: bug_status; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.bug_status AS ENUM (
'new',
'open',
'closed'
);
--
-- Name: layout_position; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.layout_position AS (
x integer,
y integer
);
--
-- Name: post_status; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.post_status AS ENUM (
'draft',
'published',
'archived'
);
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: clever_cloud_resources; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.clever_cloud_resources (
id uuid NOT NULL,
addon_id character varying(255) NOT NULL,
owner_id character varying(255) NOT NULL,
owner_name character varying(255) NOT NULL,
user_id character varying(255) NOT NULL,
plan character varying(255) NOT NULL,
region character varying(255) NOT NULL,
callback_url character varying(255) NOT NULL,
logplex_token character varying(255) NOT NULL,
options jsonb,
organization_id uuid,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
deleted_at timestamp without time zone
);
--
-- Name: events; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.events (
id uuid NOT NULL,
name character varying(255) NOT NULL,
data jsonb,
details jsonb,
created_by uuid,
created_at timestamp without time zone NOT NULL,
organization_id uuid,
project_id uuid
);
--
-- Name: COLUMN events.data; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.events.data IS 'event entity data';
--
-- Name: COLUMN events.details; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.events.details IS 'when additional data are needed';
--
-- Name: COLUMN events.project_id; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.events.project_id IS 'no FK to keep records when projects are deleted';
--
-- Name: gallery; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.gallery (
id uuid NOT NULL,
project_id uuid NOT NULL,
slug character varying(255) NOT NULL,
icon character varying(255) NOT NULL,
color character varying(255) NOT NULL,
website character varying(255) NOT NULL,
banner character varying(255) NOT NULL,
tips text NOT NULL,
description text NOT NULL,
analysis text NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL
);
--
-- Name: COLUMN gallery.website; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.gallery.website IS 'link for the website of the schema';
--
-- Name: COLUMN gallery.banner; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.gallery.banner IS 'banner image, 1600x900';
--
-- Name: COLUMN gallery.tips; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.gallery.tips IS 'shown on project creation';
--
-- Name: COLUMN gallery.description; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.gallery.description IS 'shown on list and detail view';
--
-- Name: COLUMN gallery.analysis; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.gallery.analysis IS 'markdown shown on detail view';
--
-- Name: heroku_resources; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.heroku_resources (
id uuid NOT NULL,
name character varying(255) NOT NULL,
app character varying(255),
plan character varying(255) NOT NULL,
region character varying(255) NOT NULL,
options jsonb,
callback character varying(255) NOT NULL,
oauth_code uuid NOT NULL,
oauth_type character varying(255) NOT NULL,
oauth_expire timestamp without time zone NOT NULL,
organization_id uuid,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
deleted_at timestamp without time zone
);
--
-- Name: organization_invitations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.organization_invitations (
id uuid NOT NULL,
sent_to character varying(255) NOT NULL,
organization_id uuid NOT NULL,
expire_at timestamp without time zone NOT NULL,
created_by uuid NOT NULL,
created_at timestamp without time zone NOT NULL,
cancel_at timestamp without time zone,
answered_by uuid,
refused_at timestamp without time zone,
accepted_at timestamp without time zone,
role character varying(255)
);
--
-- Name: COLUMN organization_invitations.sent_to; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.organization_invitations.sent_to IS 'email to send the invitation';
--
-- Name: organization_members; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.organization_members (
user_id uuid NOT NULL,
organization_id uuid NOT NULL,
created_by uuid NOT NULL,
updated_by uuid NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
role character varying(255) DEFAULT 'owner'::character varying NOT NULL
);
--
-- Name: COLUMN organization_members.role; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.organization_members.role IS 'values: owner, writer, reader';
--
-- Name: organizations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.organizations (
id uuid NOT NULL,
slug character varying(255) NOT NULL,
name character varying(255) NOT NULL,
logo character varying(255) NOT NULL,
description text,
github_username character varying(255),
twitter_username character varying(255),
stripe_customer_id character varying(255),
is_personal boolean NOT NULL,
created_by uuid NOT NULL,
updated_by uuid NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
deleted_by uuid,
deleted_at timestamp without time zone,
data jsonb,
plan character varying(255),
plan_freq character varying(255),
plan_status character varying(255),
plan_seats integer,
plan_validated timestamp without time zone,
free_trial_used timestamp without time zone,
gateway character varying(255)
);
--
-- Name: COLUMN organizations.is_personal; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.organizations.is_personal IS 'mimic user accounts when true';
--
-- Name: COLUMN organizations.deleted_at; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.organizations.deleted_at IS 'orga is cleared on deletion but kept for FKs';
--
-- Name: COLUMN organizations.data; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.organizations.data IS 'unstructured props for orgas';
--
-- Name: COLUMN organizations.plan; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.organizations.plan IS 'organization pricing plan, ex: free, solo, team... If null, it has to be computed and stored';
--
-- Name: COLUMN organizations.plan_freq; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.organizations.plan_freq IS 'subscription period, ex: monthly, yearly. If null, it has to be computed and stored';
--
-- Name: COLUMN organizations.plan_status; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.organizations.plan_status IS 'stripe status or ''manual'' to disable the sync with stripe';
--
-- Name: COLUMN organizations.plan_validated; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.organizations.plan_validated IS 'the last time the plan was computed and stored';
--
-- Name: COLUMN organizations.free_trial_used; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.organizations.free_trial_used IS 'when the free trial was used, null otherwise';
--
-- Name: COLUMN organizations.gateway; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.organizations.gateway IS 'custom gateway for the organization';
--
-- Name: project_tokens; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.project_tokens (
id uuid NOT NULL,
project_id uuid NOT NULL,
name character varying(255) NOT NULL,
nb_access integer NOT NULL,
last_access timestamp without time zone,
expire_at timestamp without time zone,
revoked_at timestamp without time zone,
revoked_by uuid,
created_at timestamp without time zone NOT NULL,
created_by uuid NOT NULL
);
--
-- Name: TABLE project_tokens; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON TABLE public.project_tokens IS 'grant access to projects';
--
-- Name: projects; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.projects (
id uuid NOT NULL,
organization_id uuid NOT NULL,
slug public.citext NOT NULL,
name character varying(255) NOT NULL,
description text,
encoding_version integer NOT NULL,
storage_kind character varying(255) NOT NULL,
file character varying(255),
local_owner uuid,
nb_sources integer NOT NULL,
nb_tables integer NOT NULL,
nb_columns integer NOT NULL,
nb_relations integer NOT NULL,
nb_types integer NOT NULL,
nb_comments integer NOT NULL,
nb_notes integer NOT NULL,
nb_layouts integer NOT NULL,
created_by uuid NOT NULL,
updated_by uuid NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
archived_by uuid,
archived_at timestamp without time zone,
visibility character varying(255) DEFAULT 'none'::character varying NOT NULL,
nb_memos integer DEFAULT 0 NOT NULL
);
--
-- Name: COLUMN projects.encoding_version; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.projects.encoding_version IS 'encoding version for the project';
--
-- Name: COLUMN projects.storage_kind; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.projects.storage_kind IS 'enum: local, remote';
--
-- Name: COLUMN projects.file; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.projects.file IS 'stored file reference for remote projects';
--
-- Name: COLUMN projects.local_owner; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.projects.local_owner IS 'user owning a local project';
--
-- Name: COLUMN projects.nb_types; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.projects.nb_types IS 'number of SQL custom types in the project';
--
-- Name: COLUMN projects.nb_comments; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.projects.nb_comments IS 'number of SQL comments in the project';
--
-- Name: COLUMN projects.visibility; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.projects.visibility IS 'enum: none, read, write';
--
-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.schema_migrations (
version bigint NOT NULL,
inserted_at timestamp(0) without time zone
);
--
-- Name: user_auth_tokens; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.user_auth_tokens (
id uuid NOT NULL,
user_id uuid NOT NULL,
name character varying(255) NOT NULL,
nb_access integer NOT NULL,
last_access timestamp without time zone,
expire_at timestamp without time zone,
created_at timestamp without time zone NOT NULL,
deleted_at timestamp without time zone
);
--
-- Name: user_profiles; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.user_profiles (
id uuid NOT NULL,
user_id uuid NOT NULL,
usecase character varying(255),
usage character varying(255),
role character varying(255),
location character varying(255),
description text,
company character varying(255),
company_size integer,
team_organization_id uuid,
plan character varying(255),
discovered_by character varying(255),
previously_tried character varying(255)[],
product_updates boolean,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
phone character varying(255),
industry character varying(255)
);
--
-- Name: user_tokens; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.user_tokens (
id uuid NOT NULL,
user_id uuid NOT NULL,
token bytea NOT NULL,
context character varying(255) NOT NULL,
sent_to character varying(255),
created_at timestamp without time zone NOT NULL
);
--
-- Name: TABLE user_tokens; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON TABLE public.user_tokens IS 'needed for login/pass auth';
--
-- Name: COLUMN user_tokens.sent_to; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.user_tokens.sent_to IS 'email';
--
-- Name: users; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.users (
id uuid NOT NULL,
slug public.citext NOT NULL,
name character varying(255) NOT NULL,
email public.citext NOT NULL,
provider character varying(255),
provider_uid character varying(255),
avatar character varying(255) NOT NULL,
github_username character varying(255),
twitter_username character varying(255),
is_admin boolean NOT NULL,
hashed_password character varying(255),
last_signin timestamp without time zone NOT NULL,
created_at timestamp without time zone NOT NULL,
updated_at timestamp without time zone NOT NULL,
confirmed_at timestamp without time zone,
deleted_at timestamp without time zone,
data jsonb,
onboarding character varying(255),
provider_data jsonb
);
--
-- Name: COLUMN users.slug; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.users.slug IS 'friendly id to show on url';
--
-- Name: COLUMN users.hashed_password; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.users.hashed_password IS 'present only if user used login/pass auth';
--
-- Name: COLUMN users.confirmed_at; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.users.confirmed_at IS 'on email confirm or directly for sso';
--
-- Name: COLUMN users.deleted_at; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.users.deleted_at IS 'user is cleared on deletion but kept for FKs';
--
-- Name: COLUMN users.data; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.users.data IS 'unstructured props for user';
--
-- Name: COLUMN users.onboarding; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.users.onboarding IS 'current onboarding step when not finished';
--
-- Name: COLUMN users.provider_data; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.users.provider_data IS 'connection object from provider';
--
-- Name: clever_cloud_resources clever_cloud_resources_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.clever_cloud_resources
ADD CONSTRAINT clever_cloud_resources_pkey PRIMARY KEY (id);
--
-- Name: events events_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.events
ADD CONSTRAINT events_pkey PRIMARY KEY (id);
--
-- Name: gallery gallery_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.gallery
ADD CONSTRAINT gallery_pkey PRIMARY KEY (id);
--
-- Name: heroku_resources heroku_resources_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.heroku_resources
ADD CONSTRAINT heroku_resources_pkey PRIMARY KEY (id);
--
-- Name: organization_invitations organization_invitations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.organization_invitations
ADD CONSTRAINT organization_invitations_pkey PRIMARY KEY (id);
--
-- Name: organization_members organization_members_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.organization_members
ADD CONSTRAINT organization_members_pkey PRIMARY KEY (user_id, organization_id);
--
-- Name: organizations organizations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.organizations
ADD CONSTRAINT organizations_pkey PRIMARY KEY (id);
--
-- Name: project_tokens project_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.project_tokens
ADD CONSTRAINT project_tokens_pkey PRIMARY KEY (id);
--
-- Name: projects projects_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.projects
ADD CONSTRAINT projects_pkey PRIMARY KEY (id);
--
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.schema_migrations
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
--
-- Name: CONSTRAINT schema_migrations_pkey ON schema_migrations; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON CONSTRAINT schema_migrations_pkey ON public.schema_migrations IS 'HELLO!';
--
-- Name: user_auth_tokens user_auth_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.user_auth_tokens
ADD CONSTRAINT user_auth_tokens_pkey PRIMARY KEY (id);
--
-- Name: user_profiles user_profiles_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.user_profiles
ADD CONSTRAINT user_profiles_pkey PRIMARY KEY (id);
--
-- Name: user_tokens user_tokens_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.user_tokens
ADD CONSTRAINT user_tokens_pkey PRIMARY KEY (id);
--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (id);
--
-- Name: events_created_at_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX events_created_at_index ON public.events USING btree (created_at);
--
-- Name: INDEX events_created_at_index; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON INDEX public.events_created_at_index IS 'Easy access of events by date';
--
-- Name: events_created_by_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX events_created_by_index ON public.events USING btree (created_by);
--
-- Name: events_name_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX events_name_index ON public.events USING btree (name);
--
-- Name: events_organization_id_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX events_organization_id_index ON public.events USING btree (organization_id);
--
-- Name: events_project_id_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX events_project_id_index ON public.events USING btree (project_id);
--
-- Name: gallery_project_id_index; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX gallery_project_id_index ON public.gallery USING btree (project_id);
--
-- Name: gallery_slug_index; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX gallery_slug_index ON public.gallery USING btree (slug);
--
-- Name: organization_invitations_organization_id_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX organization_invitations_organization_id_index ON public.organization_invitations USING btree (organization_id);
--
-- Name: organizations_slug_index; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX organizations_slug_index ON public.organizations USING btree (slug);
--
-- Name: organizations_stripe_customer_id_index; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX organizations_stripe_customer_id_index ON public.organizations USING btree (stripe_customer_id);
--
-- Name: projects_organization_id_slug_index; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX projects_organization_id_slug_index ON public.projects USING btree (organization_id, slug);
--
-- Name: user_tokens_context_token_index; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX user_tokens_context_token_index ON public.user_tokens USING btree (context, token);
--
-- Name: user_tokens_user_id_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX user_tokens_user_id_index ON public.user_tokens USING btree (user_id);
--
-- Name: users_email_index; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX users_email_index ON public.users USING btree (email);
--
-- Name: users_slug_index; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX users_slug_index ON public.users USING btree (slug);
--
-- Name: clever_cloud_resources clever_cloud_resources_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.clever_cloud_resources
ADD CONSTRAINT clever_cloud_resources_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES public.organizations(id);
--
-- Name: events events_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.events
ADD CONSTRAINT events_created_by_fkey FOREIGN KEY (created_by) REFERENCES public.users(id);
--
-- Name: CONSTRAINT events_created_by_fkey ON events; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON CONSTRAINT events_created_by_fkey ON public.events IS 'Link to users';
--
-- Name: events events_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.events
ADD CONSTRAINT events_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES public.organizations(id);
--
-- Name: gallery gallery_project_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.gallery
ADD CONSTRAINT gallery_project_id_fkey FOREIGN KEY (project_id) REFERENCES public.projects(id);
--
-- Name: heroku_resources heroku_resources_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.heroku_resources
ADD CONSTRAINT heroku_resources_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES public.organizations(id);
--
-- Name: organization_invitations organization_invitations_answered_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.organization_invitations
ADD CONSTRAINT organization_invitations_answered_by_fkey FOREIGN KEY (answered_by) REFERENCES public.users(id);
--
-- Name: organization_invitations organization_invitations_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.organization_invitations
ADD CONSTRAINT organization_invitations_created_by_fkey FOREIGN KEY (created_by) REFERENCES public.users(id);
--
-- Name: organization_invitations organization_invitations_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.organization_invitations
ADD CONSTRAINT organization_invitations_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES public.organizations(id);
--
-- Name: organization_members organization_members_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.organization_members
ADD CONSTRAINT organization_members_created_by_fkey FOREIGN KEY (created_by) REFERENCES public.users(id);
--
-- Name: organization_members organization_members_organization_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.organization_members
ADD CONSTRAINT organization_members_organization_id_fkey FOREIGN KEY (organization_id) REFERENCES public.organizations(id);
--
-- Name: organization_members organization_members_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.organization_members
ADD CONSTRAINT organization_members_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES public.users(id);
--
-- Name: organization_members organization_members_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.organization_members
ADD CONSTRAINT organization_members_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(id);
--
-- Name: organizations organizations_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.organizations
ADD CONSTRAINT organizations_created_by_fkey FOREIGN KEY (created_by) REFERENCES public.users(id);
--
-- Name: organizations organizations_deleted_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.organizations
ADD CONSTRAINT organizations_deleted_by_fkey FOREIGN KEY (deleted_by) REFERENCES public.users(id);
--
-- Name: organizations organizations_updated_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.organizations
ADD CONSTRAINT organizations_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES public.users(id);
--
-- Name: project_tokens project_tokens_created_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.project_tokens
ADD CONSTRAINT project_tokens_created_by_fkey FOREIGN KEY (created_by) REFERENCES public.users(id);
--
-- Name: project_tokens project_tokens_project_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--