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

31 lines
915 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",
{
created_at: timestamp("created_at", { withTimezone: true })
.notNull()
.defaultNow(),
user_id: uuid("user_id")
.notNull()
.references(() => authUsers.id),
role_id: uuid("role_id")
.notNull()
.references(() => authRoles.id),
tenant_id: bigint("tenant_id", { mode: "number" }).notNull(),
created_by: uuid("created_by").references(() => authUsers.id),
},
(table) => ({
primaryKey: [table.user_id, table.role_id, table.tenant_id],
})
)
export type AuthUserRole = typeof authUserRoles.$inferSelect
export type NewAuthUserRole = typeof authUserRoles.$inferInsert