changelogs/drizzle-seed/0.3.1.md
Example:
// schema.ts
import { integer, pgTable, text } from "drizzle-orm/pg-core";
import { relations } from "drizzle-orm/relations";
export const users = pgTable("users", {
id: integer().primaryKey(),
name: text(),
email: text(),
});
export const posts = pgTable("posts", {
id: integer().primaryKey(),
content: text(),
userId: integer().references(() => users.id),
});
export const postsRelation = relations(posts, ({ one }) => ({
user: one(users, {
fields: [posts.userId],
references: [users.id],
}),
}));
Now, seeding with the schema above will trigger a warning.
You are providing a one-to-many relation between the 'users' and 'posts' tables,
while the 'posts' table object already has foreign key constraint in the schema referencing 'users' table.
In this case, the foreign key constraint will be used.