File size: 1,175 Bytes
2c16c8c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | 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),
};
});
|