Files
FEDEO/db/schema/auth_user_roles.ts
2025-12-06 10:34:58 +01:00

31 lines
907 B
TypeScript

import { pgTable, uuid, bigint, timestamp } from "drizzle-orm/pg-core"
import { authUsers } from "./auth_users"
import { authRoles } from "./auth_roles"
export const authUserRoles = pgTable(
"auth_user_roles",
{
createdAt: timestamp("created_at", { withTimezone: true })
.notNull()
.defaultNow(),
userId: uuid("user_id")
.notNull()
.references(() => authUsers.id),
roleId: uuid("role_id")
.notNull()
.references(() => authRoles.id),
tenantId: bigint("tenant_id", { mode: "number" }).notNull(),
createdBy: uuid("created_by").references(() => authUsers.id),
},
(table) => ({
primaryKey: [table.userId, table.roleId, table.tenantId],
})
)
export type AuthUserRole = typeof authUserRoles.$inferSelect
export type NewAuthUserRole = typeof authUserRoles.$inferInsert