ZindagiAssan_Backend / src /modules /auth /auth.schema.ts
Talha812's picture
Upload 45 files
2c16c8c verified
import {
pgTable,
uuid,
text,
boolean,
timestamp,
primaryKey,
uniqueIndex,
index,
} from 'drizzle-orm/pg-core';
export const authProviders = pgTable('auth_providers', {
id: uuid('id').primaryKey(),
userId: uuid('user_id').notNull(),
providerType: text('provider_type').notNull(),
providerUserId: text('provider_user_id').notNull(),
email: text('email'),
passwordHash: text('password_hash'),
emailVerified: boolean('email_verified').default(false).notNull(),
phoneVerified: boolean('phone_verified').default(false).notNull(),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),
updatedAt: timestamp('updated_at', { withTimezone: true }).defaultNow().notNull(),
}, (table) => {
return {
uniqueProviderUserCombo: uniqueIndex('auth_providers_provider_type_provider_user_id')
.on(table.providerType, table.providerUserId),
uniqueProviderAndUserEmail: uniqueIndex('auth_providers_provider_type_user_id_email')
.on(table.providerType, table.userId, table.email),
userIdIdx: index('auth_providers_user_id_idx').on(table.userId),
};
});