Skip to content

Commit dc9c3fd

Browse files
authored
add roles based on sigs (#51)
1 parent 433435b commit dc9c3fd

File tree

28 files changed

+1379
-62
lines changed

28 files changed

+1379
-62
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ALTER TYPE "public"."roles" ADD VALUE 'sig_executive' BEFORE 'committee';--> statement-breakpoint
2+
ALTER TABLE "registrations" ALTER COLUMN "status" SET NOT NULL;--> statement-breakpoint
3+
ALTER TABLE "registrations" ALTER COLUMN "created_at" SET NOT NULL;--> statement-breakpoint
4+
ALTER TABLE "users" ADD COLUMN "sigs" json;
Lines changed: 323 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,323 @@
1+
{
2+
"id": "52a74620-b04c-4d5e-a0ff-4156cfc1055a",
3+
"prevId": "5f44ca68-1f74-4879-a8be-a8fa310f8631",
4+
"version": "7",
5+
"dialect": "postgresql",
6+
"tables": {
7+
"public.events": {
8+
"name": "events",
9+
"schema": "",
10+
"columns": {
11+
"id": {
12+
"name": "id",
13+
"type": "text",
14+
"primaryKey": true,
15+
"notNull": true
16+
},
17+
"title": {
18+
"name": "title",
19+
"type": "text",
20+
"primaryKey": false,
21+
"notNull": true
22+
},
23+
"organiser": {
24+
"name": "organiser",
25+
"type": "text",
26+
"primaryKey": false,
27+
"notNull": true
28+
},
29+
"state": {
30+
"name": "state",
31+
"type": "eventState",
32+
"typeSchema": "public",
33+
"primaryKey": false,
34+
"notNull": true,
35+
"default": "'draft'"
36+
},
37+
"priority": {
38+
"name": "priority",
39+
"type": "eventPriority",
40+
"typeSchema": "public",
41+
"primaryKey": false,
42+
"notNull": true,
43+
"default": "'default'"
44+
},
45+
"capacity": {
46+
"name": "capacity",
47+
"type": "integer",
48+
"primaryKey": false,
49+
"notNull": false
50+
},
51+
"date": {
52+
"name": "date",
53+
"type": "timestamp",
54+
"primaryKey": false,
55+
"notNull": true
56+
},
57+
"about_markdown": {
58+
"name": "about_markdown",
59+
"type": "text",
60+
"primaryKey": false,
61+
"notNull": false
62+
},
63+
"location": {
64+
"name": "location",
65+
"type": "text",
66+
"primaryKey": false,
67+
"notNull": false
68+
},
69+
"location_url": {
70+
"name": "location_url",
71+
"type": "text",
72+
"primaryKey": false,
73+
"notNull": false
74+
},
75+
"form": {
76+
"name": "form",
77+
"type": "json",
78+
"primaryKey": false,
79+
"notNull": false
80+
},
81+
"created_at": {
82+
"name": "created_at",
83+
"type": "timestamp",
84+
"primaryKey": false,
85+
"notNull": false,
86+
"default": "now()"
87+
},
88+
"updated_at": {
89+
"name": "updated_at",
90+
"type": "timestamp",
91+
"primaryKey": false,
92+
"notNull": false,
93+
"default": "now()"
94+
}
95+
},
96+
"indexes": {
97+
"state_idx": {
98+
"name": "state_idx",
99+
"columns": [
100+
{
101+
"expression": "state",
102+
"isExpression": false,
103+
"asc": true,
104+
"nulls": "last"
105+
}
106+
],
107+
"isUnique": false,
108+
"concurrently": false,
109+
"method": "btree",
110+
"with": {}
111+
}
112+
},
113+
"foreignKeys": {},
114+
"compositePrimaryKeys": {},
115+
"uniqueConstraints": {},
116+
"policies": {},
117+
"checkConstraints": {},
118+
"isRLSEnabled": false
119+
},
120+
"public.registrations": {
121+
"name": "registrations",
122+
"schema": "",
123+
"columns": {
124+
"user_id": {
125+
"name": "user_id",
126+
"type": "text",
127+
"primaryKey": false,
128+
"notNull": true
129+
},
130+
"event_id": {
131+
"name": "event_id",
132+
"type": "text",
133+
"primaryKey": false,
134+
"notNull": true
135+
},
136+
"status": {
137+
"name": "status",
138+
"type": "registrationStatus",
139+
"typeSchema": "public",
140+
"primaryKey": false,
141+
"notNull": true,
142+
"default": "'pending'"
143+
},
144+
"form_data": {
145+
"name": "form_data",
146+
"type": "json",
147+
"primaryKey": false,
148+
"notNull": false
149+
},
150+
"created_at": {
151+
"name": "created_at",
152+
"type": "timestamp",
153+
"primaryKey": false,
154+
"notNull": true,
155+
"default": "now()"
156+
},
157+
"updated_at": {
158+
"name": "updated_at",
159+
"type": "timestamp",
160+
"primaryKey": false,
161+
"notNull": false,
162+
"default": "now()"
163+
}
164+
},
165+
"indexes": {
166+
"unique_user_event": {
167+
"name": "unique_user_event",
168+
"columns": [
169+
{
170+
"expression": "user_id",
171+
"isExpression": false,
172+
"asc": true,
173+
"nulls": "last"
174+
},
175+
{
176+
"expression": "event_id",
177+
"isExpression": false,
178+
"asc": true,
179+
"nulls": "last"
180+
}
181+
],
182+
"isUnique": true,
183+
"concurrently": false,
184+
"method": "btree",
185+
"with": {}
186+
}
187+
},
188+
"foreignKeys": {
189+
"registrations_user_id_users_id_fk": {
190+
"name": "registrations_user_id_users_id_fk",
191+
"tableFrom": "registrations",
192+
"tableTo": "users",
193+
"columnsFrom": ["user_id"],
194+
"columnsTo": ["id"],
195+
"onDelete": "cascade",
196+
"onUpdate": "no action"
197+
},
198+
"registrations_event_id_events_id_fk": {
199+
"name": "registrations_event_id_events_id_fk",
200+
"tableFrom": "registrations",
201+
"tableTo": "events",
202+
"columnsFrom": ["event_id"],
203+
"columnsTo": ["id"],
204+
"onDelete": "cascade",
205+
"onUpdate": "no action"
206+
}
207+
},
208+
"compositePrimaryKeys": {
209+
"registrations_user_id_event_id_pk": {
210+
"name": "registrations_user_id_event_id_pk",
211+
"columns": ["user_id", "event_id"]
212+
}
213+
},
214+
"uniqueConstraints": {},
215+
"policies": {},
216+
"checkConstraints": {},
217+
"isRLSEnabled": false
218+
},
219+
"public.users": {
220+
"name": "users",
221+
"schema": "",
222+
"columns": {
223+
"id": {
224+
"name": "id",
225+
"type": "text",
226+
"primaryKey": true,
227+
"notNull": true
228+
},
229+
"email": {
230+
"name": "email",
231+
"type": "text",
232+
"primaryKey": false,
233+
"notNull": true
234+
},
235+
"first_name": {
236+
"name": "first_name",
237+
"type": "text",
238+
"primaryKey": false,
239+
"notNull": true
240+
},
241+
"last_name": {
242+
"name": "last_name",
243+
"type": "text",
244+
"primaryKey": false,
245+
"notNull": true
246+
},
247+
"role": {
248+
"name": "role",
249+
"type": "roles",
250+
"typeSchema": "public",
251+
"primaryKey": false,
252+
"notNull": true,
253+
"default": "'member'"
254+
},
255+
"sigs": {
256+
"name": "sigs",
257+
"type": "json",
258+
"primaryKey": false,
259+
"notNull": false
260+
},
261+
"created_at": {
262+
"name": "created_at",
263+
"type": "timestamp",
264+
"primaryKey": false,
265+
"notNull": false,
266+
"default": "now()"
267+
},
268+
"updated_at": {
269+
"name": "updated_at",
270+
"type": "timestamp",
271+
"primaryKey": false,
272+
"notNull": false,
273+
"default": "now()"
274+
}
275+
},
276+
"indexes": {},
277+
"foreignKeys": {},
278+
"compositePrimaryKeys": {},
279+
"uniqueConstraints": {
280+
"users_email_unique": {
281+
"name": "users_email_unique",
282+
"nullsNotDistinct": false,
283+
"columns": ["email"]
284+
}
285+
},
286+
"policies": {},
287+
"checkConstraints": {},
288+
"isRLSEnabled": false
289+
}
290+
},
291+
"enums": {
292+
"public.eventPriority": {
293+
"name": "eventPriority",
294+
"schema": "public",
295+
"values": ["default", "pinned"]
296+
},
297+
"public.eventState": {
298+
"name": "eventState",
299+
"schema": "public",
300+
"values": ["draft", "published"]
301+
},
302+
"public.registrationStatus": {
303+
"name": "registrationStatus",
304+
"schema": "public",
305+
"values": ["pending", "accepted", "waitlist", "rejected"]
306+
},
307+
"public.roles": {
308+
"name": "roles",
309+
"schema": "public",
310+
"values": ["member", "sig_executive", "committee"]
311+
}
312+
},
313+
"schemas": {},
314+
"sequences": {},
315+
"roles": {},
316+
"policies": {},
317+
"views": {},
318+
"_meta": {
319+
"columns": {},
320+
"schemas": {},
321+
"tables": {}
322+
}
323+
}

apps/api/drizzle/meta/_journal.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
"when": 1767533608741,
99
"tag": "0000_watery_black_tarantula",
1010
"breakpoints": true
11+
},
12+
{
13+
"idx": 1,
14+
"version": "7",
15+
"when": 1769946474409,
16+
"tag": "0001_military_juggernaut",
17+
"breakpoints": true
1118
}
1219
]
1320
}

apps/api/src/db/schema.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ import {
1616
RegistrationFormAnswer,
1717
RegistrationStatus,
1818
UserRole,
19+
Sigs,
1920
} from "@events.comp-soc.com/shared";
2021

21-
export const usersRole = pgEnum("roles", [UserRole.Member, UserRole.Committee]);
22+
export const usersRole = pgEnum("roles", [
23+
UserRole.Member,
24+
UserRole.SigExecutive,
25+
UserRole.Committee,
26+
]);
2227

2328
export const eventState = pgEnum("eventState", [EventState.Draft, EventState.Published]);
2429
export const eventPriority = pgEnum("eventPriority", [EventPriority.Default, EventPriority.Pinned]);
@@ -36,6 +41,7 @@ export const usersTable = pgTable("users", {
3641
firstName: text("first_name").notNull(),
3742
lastName: text("last_name").notNull(),
3843
role: usersRole("role").default("member").notNull(),
44+
sigs: json("sigs").$type<Sigs[]>(),
3945
createdAt: timestamp("created_at").defaultNow(),
4046
updatedAt: timestamp("updated_at")
4147
.defaultNow()

0 commit comments

Comments
 (0)