ERROR
Error seeding "jobs" in model jobs: TypeError: Cannot read properties of undefined (reading 'modelName')
✅ What works
- The
users model seeds successfully.
🧪 What I tried
- Verified the
jobs table exists in the DB ✅
- Checked Drizzle schema for
jobs — no issues found ✅
- Confirmed that field names in schema and seeding logic match ✅
- Also setting at the end of the table the config with
js table(foo, {tableName: "jobs"} that didn't work also.
- Inspected the seeding module — looks like
jobs is not registered internally ❌ (there were only table account session user and i think another one that I do not specifically remember and wasn't relevant)
🧩 Possible Cause
It seems the jobs table is not being included in the internal list of tables the module uses. This leads to the seeding library being unable to find modelName when processing the jobs seed.
🧾 Schema (jobsTable) using drizzle
export const jobsTable = pgTable("jobs", {
id: uuid().defaultRandom(),
userId: text("user_id").notNull().references(() => user.id, { onDelete: "cascade", onUpdate: "restrict" }),
title: text("title").notNull(),
description: text("description").notNull(),
client: varchar("client", { length: 100 }).notNull(),
clientRating: numeric("client_rating").notNull(),
budget_min: integer("budget_min").notNull(),
budget_max: integer("budget_max").notNull(),
timeframe: varchar("timeframe", { length: 50 }).notNull(),
language: programLang("language").notNull(),
framework: varchar("framework", { length: 50 }).notNull(),
difficulty: difficultyEnum("difficulty").notNull(),
posted: timestamp("posted", { mode: "date" }).defaultNow(),
applicants: integer("applicants").notNull(),
skills: text("skills").array().notNull(),
repository: text("repository").notNull(),
branch: varchar("branch", { length: 100 }).notNull(),
urgent: boolean("urgent").notNull(),
verified: boolean("verified").notNull(),
requirements: text("requirements").array().notNull(),
technicalDetails: jsonb("technical_details").notNull(),
});
the seed table logic
export const seed = Seed({
...users<{ user: User; session: Session; account: Account }>(
{
user: { /* ... */ },
account: { /* ... */ },
session: { /* ... */ },
},
),
jobs: table(
{
user_id: $.foreignKey({ field: "id", model: "user" }),
title: $.jobTitles(),
description: $.loremIpsum(),
client: $.first_and_lastname(),
client_rating: $.randomNumber({ min: 0, max: 50 }),
budget_min: $.randomNumber({ min: 500, max: 2000 }),
budget_max: $.randomNumber({ min: 2000, max: 10000 }),
timeframe: $.randomChoice(
$.custom(() => "1 week"),
$.custom(() => "1 month"),
$.custom(() => "3 months"),
$.custom(() => "6+ months")
),
language: $.randomChoice(
$.custom(() => "javascript"),
$.custom(() => "typescript"),
$.custom(() => "python"),
$.custom(() => "java"),
$.custom(() => "csharp"),
$.custom(() => "php"),
$.custom(() => "ruby"),
$.custom(() => "go"),
$.custom(() => "rust"),
$.custom(() => "swift"),
$.custom(() => "kotlin")
),
framework: $.randomChoice(
$.custom(() => "react"),
$.custom(() => "vue"),
$.custom(() => "angular"),
$.custom(() => "svelte"),
$.custom(() => "ember"),
$.custom(() => "next.js"),
$.custom(() => "gatsby"),
$.custom(() => "wordpress"),
$.custom(() => "laravel"),
$.custom(() => "django"),
$.custom(() => "nodejs"),
$.custom(() => "python"),
$.custom(() => "java"),
$.custom(() => "csharp"),
$.custom(() => "php"),
$.custom(() => "ruby"),
$.custom(() => "go"),
$.custom(() => "rust"),
$.custom(() => "swift"),
$.custom(() => "kotlin")
),
difficulty: $.randomChoice(
$.custom(() => "easy"),
$.custom(() => "medium"),
$.custom(() => "hard")
),
posted: $.randomDate("any"),
applicants: $.randomNumber({ min: 0, max: 50 }),
skills: $.custom(() => ["react", "typescript", "drizzle", "bun"]),
repository: $.custom(() => "https://github.com/example/repo"),
branch: $.custom(() => "main"),
urgent: $.randomBoolean(),
verified: $.randomBoolean(),
requirements: $.custom(() => ["unit tests", "CI setup", "responsive UI"]),
technical_details: $.custom(() => ({
db: "PostgreSQL",
orm: "Drizzle",
infra: "Vercel",
})),
},
),
});
ERROR
Error seeding "jobs" in model jobs: TypeError: Cannot read properties of undefined (reading 'modelName')✅ What works
usersmodel seeds successfully.🧪 What I tried
jobstable exists in the DB ✅jobs— no issues found ✅js table(foo, {tableName: "jobs"}that didn't work also.jobsis not registered internally ❌ (there were only table account session user and i think another one that I do not specifically remember and wasn't relevant)🧩 Possible Cause
It seems the
jobstable is not being included in the internal list of tables the module uses. This leads to the seeding library being unable to findmodelNamewhen processing thejobsseed.🧾 Schema (
jobsTable) using drizzlethe seed table logic