From b35302fa020ec82a9d67a6cb34379d42983d3cfc Mon Sep 17 00:00:00 2001 From: ivar Date: Wed, 14 Jan 2026 21:32:16 +0100 Subject: Misc stuff --- app/src/lib/server/db/schema.ts | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'app/src/lib/server/db') diff --git a/app/src/lib/server/db/schema.ts b/app/src/lib/server/db/schema.ts index 4d13ed6..dbff3a2 100644 --- a/app/src/lib/server/db/schema.ts +++ b/app/src/lib/server/db/schema.ts @@ -1,17 +1,17 @@ import { relations, sql } from 'drizzle-orm'; -import { numeric, text, pgTable, uuid, json } from "drizzle-orm/pg-core"; -import type { Sb1Tokens } from '../sb1'; +import { numeric, text, pgTable, uuid, jsonb } from "drizzle-orm/pg-core"; import type { SessionLogType } from '../session-log'; +import type { Sb1Tokens, Sb1Transaction, Sb1TransactionDetails } from '$lib/shared'; -export const syncSession = pgTable("session", { +export const SyncSessionTable = pgTable("session", { id: uuid('id').primaryKey().default(sql`uuidv7()`), authzState: text("authzState"), accessTokenCreated: numeric("accessTokenCreated"), refreshTokenCreated: numeric("refreshTokenCreated"), - tokens: json("tokens").$type() + tokens: jsonb("tokens").$type() }) -export const syncLog = pgTable("session_log", { +export const SyncLogTable = pgTable("session_log", { id: uuid('id').primaryKey().default(sql`uuidv7()`), sessionId: text("session_id"), dateTime: text("date_time"), @@ -19,13 +19,18 @@ export const syncLog = pgTable("session_log", { msg: text("msg") }) -export const syncLogRelation = relations(syncLog, ({ one }) => ({ - author: one(syncSession, { - fields: [syncLog.sessionId], - references: [syncSession.id], +export const TransactionsTable = pgTable("transactions", { + transaction: jsonb("transaction").$type(), + details: jsonb("details").$type() +}) + +export const SyncLogRelation = relations(SyncLogTable, ({ one }) => ({ + author: one(SyncSessionTable, { + fields: [SyncLogTable.sessionId], + references: [SyncSessionTable.id], }) })) -export const syncSessionLogRelation = relations(syncSession, ({ many }) => ({ - logs: many(syncLog) +export const SyncSessionLogRelation = relations(SyncSessionTable, ({ many }) => ({ + logs: many(SyncLogTable) })) -- cgit v1.3