This repository was archived by the owner on Sep 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
This repository was archived by the owner on Sep 3, 2025. It is now read-only.
Bug: TypeError when seeding jobs table — modelName is undefined #32
Copy link
Copy link
Open
Description
ERROR
Error seeding "jobs" in model jobs: TypeError: Cannot read properties of undefined (reading 'modelName')
✅ What works
- The
usersmodel seeds successfully.
🧪 What I tried
- Verified the
jobstable 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
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 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",
})),
},
),
});Metadata
Metadata
Assignees
Labels
No labels