mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
30 lines
947 B
TypeScript
30 lines
947 B
TypeScript
|
|
import { boolean, pgTable, text, uuid } from 'drizzle-orm/pg-core';
|
||
|
|
import { createId as cuid2 } from '@paralleldrive/cuid2';
|
||
|
|
import { type InferSelectModel, relations } from 'drizzle-orm';
|
||
|
|
import { timestamps } from '../utils';
|
||
|
|
import user_roles from './userRoles';
|
||
|
|
|
||
|
|
const usersTable = pgTable('users', {
|
||
|
|
id: uuid('id').primaryKey().defaultRandom(),
|
||
|
|
cuid: text('cuid')
|
||
|
|
.unique()
|
||
|
|
.$defaultFn(() => cuid2()),
|
||
|
|
username: text('username').unique(),
|
||
|
|
hashed_password: text('hashed_password'),
|
||
|
|
email: text('email').unique(),
|
||
|
|
first_name: text('first_name'),
|
||
|
|
last_name: text('last_name'),
|
||
|
|
verified: boolean('verified').default(false),
|
||
|
|
receive_email: boolean('receive_email').default(false),
|
||
|
|
theme: text('theme').default('system'),
|
||
|
|
...timestamps,
|
||
|
|
});
|
||
|
|
|
||
|
|
export const userRelations = relations(usersTable, ({ many }) => ({
|
||
|
|
user_roles: many(user_roles),
|
||
|
|
}));
|
||
|
|
|
||
|
|
export type Users = InferSelectModel<typeof usersTable>;
|
||
|
|
|
||
|
|
export default usersTable;
|