Skip to content

Commit 45d98da

Browse files
Setup tweaks (#18)
* rename `/landingpage` to `/(landingpage)` * create course page * use environment variable for better-auth baseURL * modify auth+schema * safe action setup tweaks * Update src/db/schema.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/lib/safe-action.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * better-auth schema changes * add role through better-auth schema * remove unnecessary role field in `auth-schema.ts` --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent f0a37d3 commit 45d98da

File tree

17 files changed

+778
-78
lines changed

17 files changed

+778
-78
lines changed

drizzle.config.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import 'dotenv/config';
1+
import "dotenv/config";
22
import { defineConfig } from "drizzle-kit";
33

44
export default defineConfig({
5-
schema: './src/db/schema.ts',
6-
dialect: 'turso',
7-
out: './drizzle',
8-
dbCredentials: {
9-
url: process.env.TURSO_DATABASE_URL!,
10-
authToken: process.env.TURSO_AUTH_TOKEN
11-
}
12-
})
5+
schema: "./src/db/schema.ts",
6+
dialect: "turso",
7+
out: "./drizzle",
8+
dbCredentials: {
9+
url: process.env.TURSO_DATABASE_URL!,
10+
authToken: process.env.TURSO_AUTH_TOKEN!,
11+
},
12+
});

drizzle/0000_yellow_hawkeye.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE TABLE `user_data` (
2+
`id` text PRIMARY KEY NOT NULL,
3+
`user_id` text NOT NULL,
4+
`role` text DEFAULT 'user' NOT NULL,
5+
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
6+
`updated_at` integer NOT NULL,
7+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
8+
);

drizzle/0001_mean_red_skull.sql

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
CREATE TABLE `accounts` (
2+
`id` text PRIMARY KEY NOT NULL,
3+
`account_id` text NOT NULL,
4+
`provider_id` text NOT NULL,
5+
`user_id` text NOT NULL,
6+
`access_token` text,
7+
`refresh_token` text,
8+
`id_token` text,
9+
`access_token_expires_at` integer,
10+
`refresh_token_expires_at` integer,
11+
`scope` text,
12+
`password` text,
13+
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
14+
`updated_at` integer NOT NULL,
15+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
16+
);
17+
--> statement-breakpoint
18+
CREATE TABLE `sessions` (
19+
`id` text PRIMARY KEY NOT NULL,
20+
`expires_at` integer NOT NULL,
21+
`token` text NOT NULL,
22+
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
23+
`updated_at` integer NOT NULL,
24+
`ip_address` text,
25+
`user_agent` text,
26+
`user_id` text NOT NULL,
27+
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
28+
);
29+
--> statement-breakpoint
30+
CREATE UNIQUE INDEX `sessions_token_unique` ON `sessions` (`token`);--> statement-breakpoint
31+
CREATE TABLE `users` (
32+
`id` text PRIMARY KEY NOT NULL,
33+
`name` text NOT NULL,
34+
`email` text NOT NULL,
35+
`email_verified` integer DEFAULT false NOT NULL,
36+
`image` text,
37+
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
38+
`updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL
39+
);
40+
--> statement-breakpoint
41+
CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);--> statement-breakpoint
42+
CREATE TABLE `verifications` (
43+
`id` text PRIMARY KEY NOT NULL,
44+
`identifier` text NOT NULL,
45+
`value` text NOT NULL,
46+
`expires_at` integer NOT NULL,
47+
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
48+
`updated_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL
49+
);

drizzle/meta/0000_snapshot.json

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"version": "6",
3+
"dialect": "sqlite",
4+
"id": "31842279-6d99-42f1-a8a2-17337da98b4f",
5+
"prevId": "00000000-0000-0000-0000-000000000000",
6+
"tables": {
7+
"user_data": {
8+
"name": "user_data",
9+
"columns": {
10+
"id": {
11+
"name": "id",
12+
"type": "text",
13+
"primaryKey": true,
14+
"notNull": true,
15+
"autoincrement": false
16+
},
17+
"user_id": {
18+
"name": "user_id",
19+
"type": "text",
20+
"primaryKey": false,
21+
"notNull": true,
22+
"autoincrement": false
23+
},
24+
"role": {
25+
"name": "role",
26+
"type": "text",
27+
"primaryKey": false,
28+
"notNull": true,
29+
"autoincrement": false,
30+
"default": "'user'"
31+
},
32+
"created_at": {
33+
"name": "created_at",
34+
"type": "integer",
35+
"primaryKey": false,
36+
"notNull": true,
37+
"autoincrement": false,
38+
"default": "(cast(unixepoch('subsecond') * 1000 as integer))"
39+
},
40+
"updated_at": {
41+
"name": "updated_at",
42+
"type": "integer",
43+
"primaryKey": false,
44+
"notNull": true,
45+
"autoincrement": false
46+
}
47+
},
48+
"indexes": {},
49+
"foreignKeys": {
50+
"user_data_user_id_users_id_fk": {
51+
"name": "user_data_user_id_users_id_fk",
52+
"tableFrom": "user_data",
53+
"tableTo": "users",
54+
"columnsFrom": [
55+
"user_id"
56+
],
57+
"columnsTo": [
58+
"id"
59+
],
60+
"onDelete": "cascade",
61+
"onUpdate": "no action"
62+
}
63+
},
64+
"compositePrimaryKeys": {},
65+
"uniqueConstraints": {},
66+
"checkConstraints": {}
67+
}
68+
},
69+
"views": {},
70+
"enums": {},
71+
"_meta": {
72+
"schemas": {},
73+
"tables": {},
74+
"columns": {}
75+
},
76+
"internal": {
77+
"indexes": {}
78+
}
79+
}

0 commit comments

Comments
 (0)