-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.js
More file actions
35 lines (32 loc) · 798 Bytes
/
schema.js
File metadata and controls
35 lines (32 loc) · 798 Bytes
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
import {
integer,
jsonb,
pgTable,
serial,
text,
timestamp,
} from "drizzle-orm/pg-core";
export const users = pgTable("users", {
id: text("id").primaryKey(),
username: text("username").unique(),
password_hash: text("password_hash"),
goal: jsonb("goal"),
});
export const sessionTable = pgTable("session", {
id: text("id").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => users.id),
expiresAt: timestamp("expires_at", {
withTimezone: true,
mode: "date",
}).notNull(),
});
export const entries = pgTable("entries", {
id: serial("id").primaryKey(),
userId: text("userid").references(() => users.id),
calories: integer("calories"),
protein: integer("protein"),
carbs: integer("carbs"),
timestamp: timestamp("timestamp"),
});