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, sql } from 'drizzle-orm';
import { numeric, text, pgTable, uuid, json } from "drizzle-orm/pg-core";
import type { Sb1Tokens } from '../sb1';
export const syncSession = pgTable("session", {
id: uuid('id').primaryKey().default(sql`uuidv7()`),
authzState: text("authzState"),
accessTokenCreated: numeric("accessTokenCreated"),
refreshTokenCreated: numeric("refreshTokenCreated"),
tokens: json("tokens").$type<Sb1Tokens>()
})
export const syncLog = pgTable("session_log", {
id: uuid('id').primaryKey().default(sql`uuidv7()`),
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)
}))
|