Files
FEDEO/backend/db/schema/user_credentials.ts
2026-01-06 12:07:43 +01:00

54 lines
1.4 KiB
TypeScript

import {
pgTable,
uuid,
timestamp,
bigint,
boolean,
jsonb,
numeric, pgEnum,
} from "drizzle-orm/pg-core"
import { tenants } from "./tenants"
import { authUsers } from "./auth_users"
import {credentialTypesEnum} from "./enums";
export const userCredentials = pgTable("user_credentials", {
id: uuid("id").primaryKey().defaultRandom(),
createdAt: timestamp("created_at", { withTimezone: true })
.notNull()
.defaultNow(),
userId: uuid("user_id")
.notNull()
.references(() => authUsers.id),
updatedAt: timestamp("updated_at", { withTimezone: true }),
tenantId: bigint("tenant_id", { mode: "number" })
.notNull()
.references(() => tenants.id),
smtpPort: numeric("smtp_port"),
smtpSsl: boolean("smtp_ssl"),
type: credentialTypesEnum("type").notNull(),
imapPort: numeric("imap_port"),
imapSsl: boolean("imap_ssl"),
emailEncrypted: jsonb("email_encrypted"),
passwordEncrypted: jsonb("password_encrypted"),
smtpHostEncrypted: jsonb("smtp_host_encrypted"),
imapHostEncrypted: jsonb("imap_host_encrypted"),
accessTokenEncrypted: jsonb("access_token_encrypted"),
refreshTokenEncrypted: jsonb("refresh_token_encrypted"),
})
export type UserCredential = typeof userCredentials.$inferSelect
export type NewUserCredential = typeof userCredentials.$inferInsert