Skip to content

Commit 50d62d7

Browse files
authored
Add Sign-Up/In. Fixed db and issues with pnpm-lock.yaml (#39)
* completed signin and signup and added role to auth-schema.ts. later will need to implement zod * Fixed pnpm-lock.yaml it was all messed up * was missing drizzle sql and changed navbars redirect * gitignore was not tracking drizzle output dirzzle/___.sql
1 parent ef6ec00 commit 50d62d7

28 files changed

+2541
-2387
lines changed

.gitignore

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@ data/*.db
4545

4646
# Drizzle migration outputs
4747
drizzle/*.sqlite
48-
drizzle/*.sql
4948

5049
# macOS and Node junk
5150
.DS_Store
52-
node_modules/
51+
node_modules/
52+
53+
# local dev database
54+
dev.db
55+
local.db
56+
local.db-shm
57+
local.db-wal

dev (1).env

Lines changed: 0 additions & 3 deletions
This file was deleted.

drizzle/0000_light_wildside.sql

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
CREATE TABLE `attachments` (
2+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
3+
`lessonId` integer NOT NULL,
4+
`title` text,
5+
`media_type` text DEFAULT 'other' NOT NULL,
6+
`blobId` integer,
7+
`external_url` text,
8+
`metadata` text DEFAULT '{}' NOT NULL,
9+
`created_at` integer DEFAULT (unixepoch()) NOT NULL,
10+
`updated_at` integer DEFAULT (unixepoch()) NOT NULL,
11+
FOREIGN KEY (`lessonId`) REFERENCES `lessons`(`id`) ON UPDATE no action ON DELETE cascade,
12+
FOREIGN KEY (`blobId`) REFERENCES `blobs`(`id`) ON UPDATE no action ON DELETE set null,
13+
CONSTRAINT "attachments_source_presence_check" CHECK(( ("attachments"."blobId" IS NOT NULL AND "attachments"."external_url" IS NULL)
14+
OR ("attachments"."blobId" IS NULL AND "attachments"."external_url" IS NOT NULL) )),
15+
CONSTRAINT "attachments_url_shape_check" CHECK(("attachments"."external_url" IS NULL OR "attachments"."external_url" GLOB 'http*://*'))
16+
);
17+
--> statement-breakpoint
18+
CREATE TABLE `blobs` (
19+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
20+
`bucket` text NOT NULL,
21+
`object_key` text NOT NULL,
22+
`version_id` text,
23+
`etag` text,
24+
`size_bytes` integer,
25+
`content_type` text,
26+
`checksum_sha256` text,
27+
`storage_class` text,
28+
`createdBy` integer,
29+
`is_deleted` integer DEFAULT false NOT NULL,
30+
`deleted_at` integer,
31+
`created_at` integer DEFAULT (unixepoch()) NOT NULL,
32+
`updated_at` integer DEFAULT (unixepoch()) NOT NULL,
33+
FOREIGN KEY (`createdBy`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null
34+
);
35+
--> statement-breakpoint
36+
CREATE UNIQUE INDEX `blobs_unique` ON `blobs` (`bucket`,`object_key`,`version_id`);--> statement-breakpoint
37+
CREATE TABLE `courses` (
38+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
39+
`title` text NOT NULL,
40+
`description` text,
41+
`difficulty` text DEFAULT 'beginner' NOT NULL,
42+
`createdBy` integer,
43+
`created_at` integer DEFAULT (unixepoch()) NOT NULL,
44+
`updated_at` integer DEFAULT (unixepoch()) NOT NULL,
45+
FOREIGN KEY (`createdBy`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE set null
46+
);
47+
--> statement-breakpoint
48+
CREATE TABLE `courses_tags` (
49+
`courseId` integer NOT NULL,
50+
`tagId` integer NOT NULL,
51+
`added_at` integer DEFAULT (unixepoch()) NOT NULL,
52+
PRIMARY KEY(`courseId`, `tagId`),
53+
FOREIGN KEY (`courseId`) REFERENCES `courses`(`id`) ON UPDATE no action ON DELETE cascade,
54+
FOREIGN KEY (`tagId`) REFERENCES `tags`(`id`) ON UPDATE no action ON DELETE cascade
55+
);
56+
--> statement-breakpoint
57+
CREATE TABLE `lessons` (
58+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
59+
`unitId` integer NOT NULL,
60+
`media_type` text DEFAULT 'markdown' NOT NULL,
61+
`content_url` text,
62+
`contentBlobId` integer,
63+
`metadata` text DEFAULT '{}' NOT NULL,
64+
`position` integer DEFAULT 1 NOT NULL,
65+
`created_at` integer DEFAULT (unixepoch()) NOT NULL,
66+
`updated_at` integer DEFAULT (unixepoch()) NOT NULL,
67+
FOREIGN KEY (`unitId`) REFERENCES `units`(`id`) ON UPDATE no action ON DELETE cascade,
68+
FOREIGN KEY (`contentBlobId`) REFERENCES `blobs`(`id`) ON UPDATE no action ON DELETE set null,
69+
CONSTRAINT "lessons_position_check" CHECK("lessons"."position" >= 1),
70+
CONSTRAINT "lessons_content_presence_check" CHECK(("lessons"."content_url" IS NOT NULL AND "lessons"."contentBlobId" IS NULL) OR ("lessons"."content_url" IS NULL AND "lessons"."contentBlobId" IS NOT NULL)),
71+
CONSTRAINT "lessons_url_shape_check" CHECK(("lessons"."content_url" IS NULL OR "lessons"."content_url" GLOB 'http*://*'))
72+
);
73+
--> statement-breakpoint
74+
CREATE TABLE `tags` (
75+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
76+
`tag_name` text NOT NULL,
77+
`created_at` integer DEFAULT (unixepoch()) NOT NULL,
78+
`updated_at` integer DEFAULT (unixepoch()) NOT NULL,
79+
CONSTRAINT "tags_tag_name_check" CHECK("tags"."tag_name" IS NOT NULL)
80+
);
81+
--> statement-breakpoint
82+
CREATE UNIQUE INDEX `tags_tag_name_unique` ON `tags` (`tag_name`);--> statement-breakpoint
83+
CREATE TABLE `units` (
84+
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
85+
`course_id` text NOT NULL,
86+
`title` text,
87+
`position` integer DEFAULT 1 NOT NULL,
88+
`created_at` integer DEFAULT (unixepoch()) NOT NULL,
89+
`updated_at` integer DEFAULT (unixepoch()) NOT NULL,
90+
FOREIGN KEY (`course_id`) REFERENCES `courses`(`id`) ON UPDATE no action ON DELETE cascade,
91+
CONSTRAINT "units_position_check" CHECK("units"."position" >= 1)
92+
);
93+
--> statement-breakpoint
94+
CREATE INDEX `units_position_index` ON `units` ("position");--> statement-breakpoint
95+
CREATE TABLE `accounts` (
96+
`id` text PRIMARY KEY NOT NULL,
97+
`account_id` text NOT NULL,
98+
`provider_id` text NOT NULL,
99+
`user_id` text NOT NULL,
100+
`access_token` text,
101+
`refresh_token` text,
102+
`id_token` text,
103+
`access_token_expires_at` integer,
104+
`refresh_token_expires_at` integer,
105+
`scope` text,
106+
`password` text,
107+
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
108+
`updated_at` integer NOT NULL,
109+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
110+
);
111+
--> statement-breakpoint
112+
CREATE TABLE `sessions` (
113+
`id` text PRIMARY KEY NOT NULL,
114+
`expires_at` integer NOT NULL,
115+
`token` text NOT NULL,
116+
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
117+
`updated_at` integer NOT NULL,
118+
`ip_address` text,
119+
`user_agent` text,
120+
`user_id` text NOT NULL,
121+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
122+
);
123+
--> statement-breakpoint
124+
CREATE UNIQUE INDEX `sessions_token_unique` ON `sessions` (`token`);--> statement-breakpoint
125+
CREATE TABLE `users` (
126+
`id` text PRIMARY KEY NOT NULL,
127+
`name` text NOT NULL,
128+
`email` text NOT NULL,
129+
`role` text DEFAULT 'user' NOT NULL,
130+
`email_verified` integer DEFAULT false NOT NULL,
131+
`image` text,
132+
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
133+
`updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL
134+
);
135+
--> statement-breakpoint
136+
CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);--> statement-breakpoint
137+
CREATE TABLE `verifications` (
138+
`id` text PRIMARY KEY NOT NULL,
139+
`identifier` text NOT NULL,
140+
`value` text NOT NULL,
141+
`expires_at` integer NOT NULL,
142+
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
143+
`updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL
144+
);

drizzle/0000_yellow_hawkeye.sql

Lines changed: 0 additions & 8 deletions
This file was deleted.

drizzle/0001_mean_red_skull.sql

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)