OleksiiKH
OleksiiKH
DTDrizzle Team
Created by Zefty on 12/14/2024 in #help
Drizzle seed stuck and no info displayed
Hi, the code above works in the latest version of drizzle-seed (0.2.1, the one without the bug) without requiring the users table to be included in the seed schema.
11 replies
DTDrizzle Team
Created by Zefty on 12/14/2024 in #help
Drizzle seed stuck and no info displayed
Yes, you can generate a hardcoded userId, as shown in the example below.
const users = pgTable("users", {
id: serial("id").primaryKey(),
});

const bloodPressure = pgTable("bloodPressure", {
bloodPressureId: serial().primaryKey(),
pressure: doublePrecision(),
userId: integer().references(() => users.id),
})

await seed(db, { bloodPressure }, {count: 10}).refine((funcs) => ({
bloodPressure: {
columns: {
userId: funcs.valuesFromArray({values: [1, 2]})
}
}
}))
const users = pgTable("users", {
id: serial("id").primaryKey(),
});

const bloodPressure = pgTable("bloodPressure", {
bloodPressureId: serial().primaryKey(),
pressure: doublePrecision(),
userId: integer().references(() => users.id),
})

await seed(db, { bloodPressure }, {count: 10}).refine((funcs) => ({
bloodPressure: {
columns: {
userId: funcs.valuesFromArray({values: [1, 2]})
}
}
}))
However, you need to ensure that the users table already contains the IDs you are providing to the valuesFromArray generator in refine.
11 replies
DTDrizzle Team
Created by Zefty on 12/14/2024 in #help
Drizzle seed stuck and no info displayed
Hi, I fixed the bug locally. It will be included in the next release. (PR -> https://github.com/drizzle-team/drizzle-orm/pull/3808)
11 replies