aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/lib/server/db/schema.ts
blob: 150d970e50dc33315278fce1aede74767bf9f336 (plain) (blame)
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
import { relations } from 'drizzle-orm';
import { numeric, text, pgTable } from "drizzle-orm/pg-core";


export const syncSession = pgTable("session", {
	id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
	authzState: text("authzState"),
	accessTokenCreated: numeric("accessTokenCreated"),
	refreshTokenCreated: numeric("refreshTokenCreated"),
	tokens: text("tokens")
})

export const syncLog = pgTable("session_log", {
	id: text("id").primaryKey(),
	sessionId: text("session_id"),
	dateTime: text("date_time"),
	msg: text("msg")
})

export const syncLogRelation = relations(syncLog, ({ one }) => ({
	author: one(syncSession, {
		fields: [syncLog.sessionId],
		references: [syncSession.id],
	})
}))

export const syncSessionLogRelation = relations(syncSession, ({ many }) => ({
	logs: many(syncLog)
}))