After this new update I am getting an introspection error schema below "drizzle-kit": "^0.21.1",

Error: There is not enough information to infer relation "public.users.twoFactorConfirmation"
export const usersRelations = relations(users, ({ one }) => ({
twoFactorConfirmation: one(twoFactorConfirmation),
}))
export const usersRelations = relations(users, ({ one }) => ({
twoFactorConfirmation: one(twoFactorConfirmation),
}))
export const twoFactorConfirmation = createTable('twoFactorConfirmation', {
id: text('id')
.primaryKey()
.$defaultFn(() => randomUUID()),
userId: text('userId').references(() => users.id, { onDelete: 'cascade' }),
})
export const twoFactorConfirmation = createTable('twoFactorConfirmation', {
id: text('id')
.primaryKey()
.$defaultFn(() => randomUUID()),
userId: text('userId').references(() => users.id, { onDelete: 'cascade' }),
})
export const users = createTable(
'user',
{
id: text('id')
.primaryKey()
.$defaultFn(() => randomUUID()),
image: text('image'),
name: text('name'),
email: text('email').notNull().unique(),
emailVerified: timestamp('emailVerified', { mode: 'date' }),
password: text('password'),
role: text('role').notNull().default('USER'),
phoneNumber: text('phone_number'),
phoneVerified: timestamp('phone_verified', { mode: 'date' }),
phoneVerificationCode: text('phone_verification_code'),
createdAt: timestamp('created_at')
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp('updatedAt'),
isTwoFactorEnabled: boolean('isTwoFactorEnabled').default(false),
stripeCustomerId: text('stripeCustomerId'),
paymentStatus: text('paymentStatus', {
enum: ['paid', 'unpaid', 'no_payment_required'],
}),
},
(example) => ({
nameIndex: index('name_idx').on(example.name),
})
)
export const users = createTable(
'user',
{
id: text('id')
.primaryKey()
.$defaultFn(() => randomUUID()),
image: text('image'),
name: text('name'),
email: text('email').notNull().unique(),
emailVerified: timestamp('emailVerified', { mode: 'date' }),
password: text('password'),
role: text('role').notNull().default('USER'),
phoneNumber: text('phone_number'),
phoneVerified: timestamp('phone_verified', { mode: 'date' }),
phoneVerificationCode: text('phone_verification_code'),
createdAt: timestamp('created_at')
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp('updatedAt'),
isTwoFactorEnabled: boolean('isTwoFactorEnabled').default(false),
stripeCustomerId: text('stripeCustomerId'),
paymentStatus: text('paymentStatus', {
enum: ['paid', 'unpaid', 'no_payment_required'],
}),
},
(example) => ({
nameIndex: index('name_idx').on(example.name),
})
)
2 Replies
2armedlopin
2armedlopinOP8mo ago
Any help available?
⚡Z.E.U.S⚡
⚡Z.E.U.S⚡8mo ago
@2armedlopin Hey! In your case twoFactorConfirmation have one user and users have many twoFactorConfirmations https://orm.drizzle.team/docs/rqb#one-to-many
export const twoFactorConfirmationRelations = relations(
twoFactorConfirmation,
({ one }) => ({
users: one(users, {
fields: [twoFactorConfirmation.userId],
references: [users.id],
}),
})
);

export const usersRelations = relations(users, ({ many }) => ({
twoFactorConfirmations: many(twoFactorConfirmation),
}));
export const twoFactorConfirmationRelations = relations(
twoFactorConfirmation,
({ one }) => ({
users: one(users, {
fields: [twoFactorConfirmation.userId],
references: [users.id],
}),
})
);

export const usersRelations = relations(users, ({ many }) => ({
twoFactorConfirmations: many(twoFactorConfirmation),
}));
Drizzle ORM - Query
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Want results from more Discord servers?
Add your server