Spaces:
Sleeping
Sleeping
| import { pgTable, uuid, varchar, text, timestamp, boolean } from 'drizzle-orm/pg-core'; | |
| // Better-Auth required tables | |
| export const user = pgTable('user', { | |
| id: text('id').primaryKey(), | |
| name: text('name'), | |
| email: text('email').unique().notNull(), | |
| emailVerified: boolean('email_verified').default(false), | |
| image: text('image'), | |
| createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), | |
| updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(), | |
| }); | |
| export const session = pgTable('session', { | |
| id: text('id').primaryKey(), | |
| userId: text('user_id').notNull().references(() => user.id, { onDelete: 'cascade' }), | |
| token: text('token').unique().notNull(), | |
| expiresAt: timestamp('expires_at', { withTimezone: true }).notNull(), | |
| ipAddress: text('ip_address'), | |
| userAgent: text('user_agent'), | |
| createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), | |
| updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(), | |
| }); | |
| export const account = pgTable('account', { | |
| id: text('id').primaryKey(), | |
| userId: text('user_id').notNull().references(() => user.id, { onDelete: 'cascade' }), | |
| accountId: text('account_id').notNull(), | |
| providerId: text('provider_id').notNull(), | |
| accessToken: text('access_token'), | |
| refreshToken: text('refresh_token'), | |
| accessTokenExpiresAt: timestamp('access_token_expires_at', { withTimezone: true }), | |
| refreshTokenExpiresAt: timestamp('refresh_token_expires_at', { withTimezone: true }), | |
| scope: text('scope'), | |
| idToken: text('id_token'), | |
| password: text('password'), | |
| createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), | |
| updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(), | |
| }); | |
| export const verification = pgTable('verification', { | |
| id: text('id').primaryKey(), | |
| identifier: text('identifier').notNull(), | |
| value: text('value').notNull(), | |
| expiresAt: timestamp('expires_at', { withTimezone: true }).notNull(), | |
| createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), | |
| updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(), | |
| }); | |
| // Application-owned user_profiles table | |
| export const userProfiles = pgTable('user_profiles', { | |
| id: uuid('id').primaryKey().defaultRandom(), | |
| authUserId: varchar('auth_user_id', { length: 255 }).unique().notNull(), | |
| programmingLanguages: text('programming_languages').array().notNull(), | |
| frameworksPlatforms: text('frameworks_platforms').array().notNull(), | |
| experienceLevel: varchar('experience_level', { length: 20 }).notNull(), | |
| deviceType: varchar('device_type', { length: 20 }).notNull(), | |
| operatingSystem: varchar('operating_system', { length: 20 }).notNull(), | |
| systemCapability: varchar('system_capability', { length: 10 }).notNull(), | |
| createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), | |
| updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(), | |
| }); | |
| export type UserProfile = typeof userProfiles.$inferSelect; | |
| export type NewUserProfile = typeof userProfiles.$inferInsert; | |