drizzle-seed breaks when trying to follow the one-to-one example

I am attempting to follow along with the One-to-one relation guide ( https://orm.drizzle.team/docs/relations#one-to-one ) The only difference is that I am using mysql (actually mariaDB) Here's my schema:
// /src/lib/db/schema.ts

import { mysqlTable, int, varchar } from 'drizzle-orm/mysql-core';
import { relations } from 'drizzle-orm';

export const users = mysqlTable('users', {
id: int('id').primaryKey(),
name: varchar('name', { length: 50 }),
});

export const usersRelations = relations(users, ({ one }) => ({
profileInfo: one(profileInfo),
}));

export const profileInfo = mysqlTable('profile_info', {
id: int('id').primaryKey(),
userId: int('user_id').references(() => users.id),
bio: varchar('bio', { length: 255 }),
});

export const profileInfoRelations = relations(profileInfo, ({ one }) => ({
user: one(users, { fields: [profileInfo.userId], references: [users.id] }),
}));
// /src/lib/db/schema.ts

import { mysqlTable, int, varchar } from 'drizzle-orm/mysql-core';
import { relations } from 'drizzle-orm';

export const users = mysqlTable('users', {
id: int('id').primaryKey(),
name: varchar('name', { length: 50 }),
});

export const usersRelations = relations(users, ({ one }) => ({
profileInfo: one(profileInfo),
}));

export const profileInfo = mysqlTable('profile_info', {
id: int('id').primaryKey(),
userId: int('user_id').references(() => users.id),
bio: varchar('bio', { length: 255 }),
});

export const profileInfoRelations = relations(profileInfo, ({ one }) => ({
user: one(users, { fields: [profileInfo.userId], references: [users.id] }),
}));
When I run my drizzle-seed script:
await seed(db, schema).refine((f) => ({
users: {
columns: 10,
with: {
profileInfo: 1
}
}
}));
await seed(db, schema).refine((f) => ({
users: {
columns: 10,
with: {
profileInfo: 1
}
}
}));
Then I get thrown this warning and error. Why is that? is it a bug? or is the example faulty? or both? To my understanding: - the warning is at the very least a bug, because I'm not defining a one-to-many relation AFAIK - the example must be faulty for me to run into a TypeError here?
Drizzle ORM - Relations
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
No description
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?