forked from Hermanoid/GTNH-AE2-OC-GOG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostgres.sql
173 lines (149 loc) · 5.41 KB
/
postgres.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
create table
public.auth (
id bigint generated by default as identity,
created_at timestamp with time zone not null default now(),
username text not null,
constraint auth_pkey primary key (id)
) tablespace pg_default;
create table
public.craftables (
id bigint generated by default as identity,
created_at timestamp with time zone not null default now(),
item_name text not null,
to_delete boolean not null default false,
constraint craftables_pkey primary key (id)
) tablespace pg_default;
create table
public.crafts (
id bigint generated by default as identity,
created_at timestamp with time zone not null default now(),
ended_at timestamp with time zone null,
started_by text null,
save boolean not null default false,
item_name text not null,
quantity bigint not null,
instruction_id bigint null,
cpu_name text not null,
constraint crafts_pkey primary key (id)
) tablespace pg_default;
create table
public.inserts (
id bigint generated by default as identity,
created_at timestamp with time zone not null default now(),
type text null,
constraint insert_pkey primary key (id)
) tablespace pg_default;
create table
public.cpus (
id bigint generated by default as identity,
name text not null,
pending_items jsonb not null,
stored_items jsonb not null,
active_items jsonb not null,
busy boolean not null,
storage bigint not null,
final_output jsonb null,
insert_id bigint null,
constraint cpus_pkey primary key (id),
constraint cpus_insert_id_fkey foreign key (insert_id) references inserts (id) on delete cascade
) tablespace pg_default;
create index if not exists inserts_id_idx on public.inserts using btree (id) tablespace pg_default;
create table
public.instructions (
id bigint generated by default as identity,
created_at timestamp with time zone not null default now(),
updated_at timestamp with time zone not null default now(),
sent_by text not null,
status text not null,
type text not null,
data jsonb not null,
message text null,
started_at timestamp with time zone null,
ended_at timestamp with time zone null,
constraint instructions_pkey primary key (id)
) tablespace pg_default;
create table
public.item_crafting_status (
id bigint generated by default as identity,
created_at timestamp with time zone not null default now(),
item_name text not null,
active_count bigint not null,
pending_count bigint not null,
stored_count bigint not null,
craft_id bigint not null,
constraint item_crafting_status_pkey primary key (id),
constraint item_crafting_status_craft_id_fkey foreign key (craft_id) references crafts (id) on update cascade on delete cascade
) tablespace pg_default;
create table
public.items (
id integer generated by default as identity,
quantity bigint not null default '0'::bigint,
item_name text not null,
insert_id bigint not null,
constraint Items_pkey primary key (id),
constraint items_insert_id_fkey foreign key (insert_id) references inserts (id) on delete cascade
) tablespace pg_default;
create index if not exists items_item_name_idx on public.items using btree (item_name) tablespace pg_default;
create table
public.mc_auth (
id bigint generated by default as identity,
created_at timestamp with time zone not null default now(),
uid uuid not null,
username text not null,
constraint mc_auth_pkey primary key (id)
) tablespace pg_default;
create table
public.stats (
id bigint generated by default as identity,
tps double precision not null,
mspt double precision not null,
eu text not null,
insert_id bigint not null,
"euIn" double precision not null,
"euOut" double precision not null,
constraint stats_pkey primary key (id),
constraint stats_insert_id_fkey foreign key (insert_id) references inserts (id) on delete cascade
) tablespace pg_default;
CREATE POLICY "Enable read access for all users"
ON "public"."cpus"
TO public
USING ( true );
CREATE POLICY "Enable read access for all users"
ON "public"."craftables"
TO public
USING ( true );
CREATE POLICY "Allow updates if user's uid is whitelisted"
ON "public"."crafts"
TO authenticated
USING ( (EXISTS ( SELECT 1
FROM (mc_auth
JOIN auth ON ((mc_auth.username = auth.username)))
WHERE (mc_auth.uid = (((auth.jwt() -> 'user_metadata'::text) ->> 'uid'::text))::uuid))) );
CREATE POLICY "Enable read access for all users"
ON "public"."crafts"
TO public
USING ( true );
CREATE POLICY "Enable read access for all users"
ON "public"."inserts"
TO public
USING ( true );
CREATE POLICY "Enable read access for all users"
ON "public"."instructions"
TO public
USING ( true );
CREATE POLICY "Enable read access for all users"
ON "public"."item_crafting_status"
TO public
USING ( true );
CREATE POLICY "Enable read access for all users"
ON "public"."items"
TO public
USING ( true );
CREATE POLICY "Enable read access for all users"
ON "public"."mc_auth"
TO public
USING ( true );
CREATE POLICY "Enable read access for all users"
ON "public"."stats"
TO public
USING ( true );