diff options
| author | ivar <i@oiee.no> | 2026-01-14 21:32:16 +0100 |
|---|---|---|
| committer | ivar <i@oiee.no> | 2026-01-14 21:32:16 +0100 |
| commit | b35302fa020ec82a9d67a6cb34379d42983d3cfc (patch) | |
| tree | 6d9ece54091d96589c9d8b0fa8ec4181c60913e7 /app/src/lib/server/db/schema.ts | |
| parent | 5a5717699b8b2d60b7d92c2087ed2cc22667e1cc (diff) | |
| download | sparebank1-actualbudget-master.tar.xz sparebank1-actualbudget-master.zip | |
Diffstat (limited to 'app/src/lib/server/db/schema.ts')
| -rw-r--r-- | app/src/lib/server/db/schema.ts | 27 |
1 files changed, 16 insertions, 11 deletions
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<Sb1Tokens>() + tokens: jsonb("tokens").$type<Sb1Tokens>() }) -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<Sb1Transaction>(), + details: jsonb("details").$type<Sb1TransactionDetails>() +}) + +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) })) |
