Skip to content

Commit 0eb3ed6

Browse files
Turso migration (#172)
1 parent faa5332 commit 0eb3ed6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2014
-18138
lines changed

apps/web/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
"date-fns-tz": "^3.1.3",
5555
"db": "workspace:*",
5656
"dotenv": "^16.4.5",
57-
"drizzle-orm": "^0.31.2",
58-
"drizzle-zod": "^0.5.1",
57+
"drizzle-orm": "^0.39.3",
58+
"drizzle-zod": "^0.7.0",
5959
"embla-carousel": "8.1.7",
6060
"embla-carousel-autoplay": "8.1.7",
6161
"embla-carousel-react": "8.1.7",

apps/web/src/app/not-found.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import Link from 'next/link'
1+
import Link from "next/link";
22

33
// TODO: make this look better
4-
4+
55
export default function NotFound() {
6-
return (
7-
<div>
8-
<h2>Not Found</h2>
9-
<p>Could not find requested resource</p>
10-
<Link href="/">Return Home</Link>
11-
</div>
12-
)
6+
return (
7+
<div>
8+
<h2>Not Found</h2>
9+
<p>Could not find requested resource</p>
10+
<Link href="/">Return Home</Link>
11+
</div>
12+
);
1313
}
1414

1515
export const runtime = "edge";

apps/web/src/validators/event.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import c from "config";
77
export const newEventFormSchema = createInsertSchema(events, {
88
title: z.string().min(1),
99
description: z.string().min(1),
10-
location: z.string().min(1),
1110
startTime: z.date(),
1211
endTime: z.date(),
13-
host: z.string().optional(),
12+
host: z.string().max(255).nullable(),
1413
type: z.enum(Object.keys(c.eventTypes) as EventTypeEnum),
1514
}).refine(({ startTime, endTime }) => startTime < endTime, {
1615
message: "Start time must be before end time",

apps/web/src/validators/shared/registration.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,19 @@ export const hackerRegistrationValidatorLocalStorage =
197197
.or(z.string())
198198
.pipe(z.coerce.number()),
199199
accommodationNote: z.string(),
200+
skills: z
201+
.array(
202+
z.object({
203+
id: z.string().min(1).max(50),
204+
text: z.string().min(1).max(50),
205+
}),
206+
)
207+
.min(1, {
208+
message: "You must have at least one skill",
209+
})
210+
.max(c.registration.maxNumberOfSkills, {
211+
message: `You cannot have more than ${c.registration.maxNumberOfSkills} skills`,
212+
}),
200213
})
201214
.omit({
202215
clerkID: true,

packages/config/hackkit.config.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,16 @@ const perms = [
998998
"super_admin",
999999
] as const;
10001000

1001+
const discordInviteStatus = ["pending", "accepted", "declined"] as const;
1002+
1003+
const ticketStatus = ["awaiting", "in_progress", "completed"] as const;
1004+
const discordVerificationStatus = [
1005+
"pending",
1006+
"expired",
1007+
"accepted",
1008+
"rejected",
1009+
] as const;
1010+
10011011
// These are routes (pages) which do not require a account / authentication. They are used in the authMiddleware in middleware.ts. Be careful which routes you add here!
10021012

10031013
const publicRoutes = [
@@ -1010,4 +1020,12 @@ const publicRoutes = [
10101020
];
10111021

10121022
export default c;
1013-
export { defaultTheme, bucketResumeBaseUploadUrl, perms, publicRoutes };
1023+
export {
1024+
defaultTheme,
1025+
bucketResumeBaseUploadUrl,
1026+
perms,
1027+
discordInviteStatus,
1028+
ticketStatus,
1029+
discordVerificationStatus,
1030+
publicRoutes,
1031+
};

packages/db/drizzle.config.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,13 @@ dotenv.config({
55
path: "../../.env",
66
});
77

8-
// export default {
9-
// schema: "./schema.ts",
10-
// out: "./drizzle",
11-
// // driver: "pg", Can be removed as of version 0.21.0 or above https://orm.drizzle.team/kit-docs/upgrade-21
12-
// dbCredentials: {
13-
// connectionString: `${process.env.POSTGRES_URL as string}?sslmode=require`,
14-
// },
15-
// breakpoints: true,
16-
// } satisfies Config;
17-
18-
// driver: "pg", Can be removed as of version 0.21.0 or above https://orm.drizzle.team/kit-docs/upgrade-21
19-
// Connection string also removed
20-
218
export default defineConfig({
229
schema: "./schema.ts",
23-
dialect: "postgresql",
2410
out: "./drizzle",
11+
dialect: "turso",
2512
dbCredentials: {
26-
url: `${process.env.POSTGRES_URL as string}?sslmode=require`,
13+
url: process.env.TURSO_DATABASE_URL!,
14+
authToken: process.env.TURSO_AUTH_TOKEN,
2715
},
2816
breakpoints: true,
2917
});
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
CREATE TABLE `chat_messages` (
2+
`id` integer PRIMARY KEY NOT NULL,
3+
`chat_id` text NOT NULL,
4+
`message` text NOT NULL,
5+
`author_id` text NOT NULL,
6+
`created_at` integer DEFAULT (current_timestamp) NOT NULL
7+
);
8+
--> statement-breakpoint
9+
CREATE TABLE `chats` (
10+
`id` text PRIMARY KEY NOT NULL,
11+
`type` text NOT NULL,
12+
`ticket_id` text,
13+
`author` text NOT NULL,
14+
`created_at` integer DEFAULT (current_timestamp) NOT NULL,
15+
FOREIGN KEY (`ticket_id`) REFERENCES `tickets`(`id`) ON UPDATE no action ON DELETE no action
16+
);
17+
--> statement-breakpoint
18+
CREATE TABLE `chats_to_users` (
19+
`chat_id` text NOT NULL,
20+
`user_id` text NOT NULL,
21+
PRIMARY KEY(`user_id`, `chat_id`),
22+
FOREIGN KEY (`chat_id`) REFERENCES `chats`(`id`) ON UPDATE no action ON DELETE no action,
23+
FOREIGN KEY (`user_id`) REFERENCES `user_common_data`(`clerk_id`) ON UPDATE no action ON DELETE no action
24+
);
25+
--> statement-breakpoint
26+
CREATE TABLE `discord_verification` (
27+
`code` text(255) PRIMARY KEY NOT NULL,
28+
`created_at` integer DEFAULT (current_timestamp) NOT NULL,
29+
`clerk_id` text(255),
30+
`discord_user_id` text(255) NOT NULL,
31+
`discord_user_tag` text(255) NOT NULL,
32+
`discord_profile_photo` text(255) NOT NULL,
33+
`discord_name` text(255) NOT NULL,
34+
`status` text DEFAULT 'pending' NOT NULL,
35+
`guild` text(100) NOT NULL
36+
);
37+
--> statement-breakpoint
38+
CREATE TABLE `error_log` (
39+
`id` text(50) PRIMARY KEY NOT NULL,
40+
`created_at` integer DEFAULT (current_timestamp) NOT NULL,
41+
`user_id` text(255),
42+
`route` text(255),
43+
`message` text NOT NULL
44+
);
45+
--> statement-breakpoint
46+
CREATE TABLE `events` (
47+
`id` integer PRIMARY KEY NOT NULL,
48+
`name` text(255) NOT NULL,
49+
`start_time` integer NOT NULL,
50+
`end_time` integer NOT NULL,
51+
`location` text(255) DEFAULT 'TBD',
52+
`points` integer DEFAULT 0 NOT NULL,
53+
`description` text NOT NULL,
54+
`type` text(50) NOT NULL,
55+
`host` text(255),
56+
`hidden` integer DEFAULT false NOT NULL
57+
);
58+
--> statement-breakpoint
59+
CREATE TABLE `files` (
60+
`id` text(255) PRIMARY KEY NOT NULL,
61+
`presigned_url` text NOT NULL,
62+
`key` text(500) NOT NULL,
63+
`validated` integer DEFAULT false NOT NULL,
64+
`type` text NOT NULL,
65+
`owner_id` text(255) NOT NULL
66+
);
67+
--> statement-breakpoint
68+
CREATE UNIQUE INDEX `files_id_unique` ON `files` (`id`);--> statement-breakpoint
69+
CREATE UNIQUE INDEX `files_key_unique` ON `files` (`key`);--> statement-breakpoint
70+
CREATE TABLE `invites` (
71+
`invitee_id` text(255) NOT NULL,
72+
`team_id` text(50) NOT NULL,
73+
`created_at` integer DEFAULT (current_timestamp) NOT NULL,
74+
`status` text DEFAULT 'pending' NOT NULL,
75+
PRIMARY KEY(`invitee_id`, `team_id`)
76+
);
77+
--> statement-breakpoint
78+
CREATE TABLE `scans` (
79+
`updated_at` integer DEFAULT (current_timestamp) NOT NULL,
80+
`user_id` text(255) NOT NULL,
81+
`event_id` integer NOT NULL,
82+
`count` integer NOT NULL,
83+
PRIMARY KEY(`user_id`, `event_id`)
84+
);
85+
--> statement-breakpoint
86+
CREATE TABLE `teams` (
87+
`id` text(50) PRIMARY KEY NOT NULL,
88+
`name` text(255) NOT NULL,
89+
`tag` text(50) NOT NULL,
90+
`bio` text,
91+
`photo` text(400) NOT NULL,
92+
`created_at` integer DEFAULT (current_timestamp) NOT NULL,
93+
`owner_id` text(255) NOT NULL,
94+
`devpost_url` text(255)
95+
);
96+
--> statement-breakpoint
97+
CREATE UNIQUE INDEX `teams_id_unique` ON `teams` (`id`);--> statement-breakpoint
98+
CREATE UNIQUE INDEX `teams_tag_unique` ON `teams` (`tag`);--> statement-breakpoint
99+
CREATE TABLE `tickets` (
100+
`id` text PRIMARY KEY NOT NULL,
101+
`title` text(255) NOT NULL,
102+
`description` text NOT NULL,
103+
`status` text DEFAULT 'awaiting' NOT NULL,
104+
`created_at` integer DEFAULT (current_timestamp) NOT NULL
105+
);
106+
--> statement-breakpoint
107+
CREATE TABLE `tickets_to_users` (
108+
`ticket_id` text NOT NULL,
109+
`user_id` text NOT NULL,
110+
PRIMARY KEY(`user_id`, `ticket_id`),
111+
FOREIGN KEY (`ticket_id`) REFERENCES `tickets`(`id`) ON UPDATE no action ON DELETE no action,
112+
FOREIGN KEY (`user_id`) REFERENCES `user_common_data`(`clerk_id`) ON UPDATE no action ON DELETE no action
113+
);
114+
--> statement-breakpoint
115+
CREATE TABLE `user_common_data` (
116+
`clerk_id` text(255) PRIMARY KEY NOT NULL,
117+
`first_name` text(50) NOT NULL,
118+
`last_name` text(50) NOT NULL,
119+
`email` text(255) NOT NULL,
120+
`hacker_tag` text(50) NOT NULL,
121+
`age` integer NOT NULL,
122+
`gender` text(50) NOT NULL,
123+
`race` text(75) NOT NULL,
124+
`ethnicity` text(50) NOT NULL,
125+
`shirt_size` text(5) NOT NULL,
126+
`diet_restrictions` text DEFAULT '[]' NOT NULL,
127+
`accommodation_note` text,
128+
`discord` text(60),
129+
`pronouns` text(20) NOT NULL,
130+
`bio` text NOT NULL,
131+
`skills` text DEFAULT '[]' NOT NULL,
132+
`profile_photo` text(255) NOT NULL,
133+
`phone_number` text(30) NOT NULL,
134+
`country_of_residence` text(3) NOT NULL,
135+
`is_fully_registered` integer DEFAULT false NOT NULL,
136+
`signup_time` integer DEFAULT (current_timestamp) NOT NULL,
137+
`is_searchable` integer DEFAULT true NOT NULL,
138+
`role` text DEFAULT 'hacker' NOT NULL,
139+
`checkin_timestamp` integer,
140+
`is_rsvped` integer DEFAULT false NOT NULL,
141+
`is_approved` integer DEFAULT false NOT NULL
142+
);
143+
--> statement-breakpoint
144+
CREATE UNIQUE INDEX `user_common_data_email_unique` ON `user_common_data` (`email`);--> statement-breakpoint
145+
CREATE UNIQUE INDEX `user_common_data_hacker_tag_unique` ON `user_common_data` (`hacker_tag`);--> statement-breakpoint
146+
CREATE TABLE `user_hacker_data` (
147+
`clerk_id` text(255) PRIMARY KEY NOT NULL,
148+
`university` text(200) NOT NULL,
149+
`major` text(200) NOT NULL,
150+
`school_id` text(50) NOT NULL,
151+
`level_of_study` text(50) NOT NULL,
152+
`hackathons_attended` integer NOT NULL,
153+
`software_experience` text(25) NOT NULL,
154+
`heard_from` text(50),
155+
`github` text(100),
156+
`linkedin` text(100),
157+
`personal_website` text(100),
158+
`resume` text(255) DEFAULT 'https://static.acmutsa.org/No%20Resume%20Provided.pdf' NOT NULL,
159+
`group` integer NOT NULL,
160+
`team_id` text(50),
161+
`points` integer DEFAULT 0 NOT NULL,
162+
`has_accepted_mlh_coc` integer NOT NULL,
163+
`has_shared_data_with_mlh` integer NOT NULL,
164+
`is_emailable` integer NOT NULL,
165+
FOREIGN KEY (`clerk_id`) REFERENCES `user_common_data`(`clerk_id`) ON UPDATE no action ON DELETE cascade
166+
);

0 commit comments

Comments
 (0)