aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/lib/server/db/schema.ts
diff options
context:
space:
mode:
authorivar <i@oiee.no>2025-12-10 00:17:27 +0100
committerivar <i@oiee.no>2025-12-10 00:17:27 +0100
commit57861411f37a07af3cd8fcf1520843e5a5e44bfc (patch)
tree86fdb1024fdadfcf6551cbb5da274beb791499d9 /app/src/lib/server/db/schema.ts
downloadsparebank1-actualbudget-57861411f37a07af3cd8fcf1520843e5a5e44bfc.tar.xz
sparebank1-actualbudget-57861411f37a07af3cd8fcf1520843e5a5e44bfc.zip
Initial commit
Diffstat (limited to 'app/src/lib/server/db/schema.ts')
-rw-r--r--app/src/lib/server/db/schema.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/src/lib/server/db/schema.ts b/app/src/lib/server/db/schema.ts
new file mode 100644
index 0000000..c1bea43
--- /dev/null
+++ b/app/src/lib/server/db/schema.ts
@@ -0,0 +1,28 @@
+import { relations } from 'drizzle-orm';
+import { int, sqliteTable, text } from 'drizzle-orm/sqlite-core';
+
+export const syncSession = sqliteTable("session", {
+ id: text('id').primaryKey().$defaultFn(() => crypto.randomUUID()),
+ authzState: text("authzState"),
+ accessTokenCreated: int("accessTokenCreated"),
+ refreshTokenCreated: int("refreshTokenCreated"),
+ tokens: text("tokens")
+})
+
+export const syncLog = sqliteTable("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)
+}))