adrtivv
adrtivv
DTDrizzle Team
Created by roze789 on 12/4/2024 in #help
PgEnum Error on relation
so for example, instead of mapping wholesalerName as wholesaler_name, it might be mapping it to wholesalername, probably
10 replies
DTDrizzle Team
Created by roze789 on 12/4/2024 in #help
PgEnum Error on relation
i just remembered having this problem a few months ago and this solved it as for your question, i think the issue with mapping could be this: https://orm.drizzle.team/docs/sql-schema-declaration#camel-and-snake-casing
10 replies
DTDrizzle Team
Created by roze789 on 12/4/2024 in #help
PgEnum Error on relation
try this
wholesalerName: wholesalerNameEnum("wholesaler_name").notNull()
wholesalerName: wholesalerNameEnum("wholesaler_name").notNull()
10 replies
DTDrizzle Team
Created by adrtivv on 11/6/2024 in #help
column is of type date but expression is of type text
await db.update(users).set({ dateOfBirth: null }).where(eq(users.id, id)).returning();

{
sql: `
update
"users"
set
"date_of_birth" = $1
where
"users"."id" = $2 returning "date_of_birth", "id"
`,
params: [null, "01930105-b607-7f81-ada2-d5ea49b393f3"],
}
await db.update(users).set({ dateOfBirth: null }).where(eq(users.id, id)).returning();

{
sql: `
update
"users"
set
"date_of_birth" = $1
where
"users"."id" = $2 returning "date_of_birth", "id"
`,
params: [null, "01930105-b607-7f81-ada2-d5ea49b393f3"],
}
await db.update(users).set({
dateOfBirth: sql`(case when ${users.id} = ${id} then ${null} end)`
}).where(inArray(users.id, [id])).returning();

{
sql: `
update
"users"
set
"date_of_birth" =
(
case
when
"users"."id" = $1
then
$2
end
)
where
"users"."id" in
(
$3
)
returning "date_of_birth", "id"
`,
params: [
"01930105-b607-7f81-ada2-d5ea49b393f3",
null,
"01930105-b607-7f81-ada2-d5ea49b393f3",
],
}
await db.update(users).set({
dateOfBirth: sql`(case when ${users.id} = ${id} then ${null} end)`
}).where(inArray(users.id, [id])).returning();

{
sql: `
update
"users"
set
"date_of_birth" =
(
case
when
"users"."id" = $1
then
$2
end
)
where
"users"."id" in
(
$3
)
returning "date_of_birth", "id"
`,
params: [
"01930105-b607-7f81-ada2-d5ea49b393f3",
null,
"01930105-b607-7f81-ada2-d5ea49b393f3",
],
}
Both update operations have the same functionality, but in the second case I get column \"date_of_birth\" is of type date but expression is of type text error.
6 replies
DTDrizzle Team
Created by adrtivv on 11/4/2024 in #help
How to resolve mutiple queries in a single request to postgres database?
I would need to use Promise.all at multiple places so it can compound a lot. I'm not relying on postgres exceptions so in my code I have to do constraint checks, there's also authorization checks and business logic checks etc., and all that in a single operation. So, for example in a bulk update operation this could result in too many promises.
6 replies
DTDrizzle Team
Created by Acro on 3/21/2024 in #help
When to use what? drizzle-kit push:* Vs. having a file with drizzle migrate client?
any difference between drizzle kit migrate command and migrate() function if both are executed against the same migration files?
6 replies
DTDrizzle Team
Created by adrtivv on 11/27/2023 in #help
drizzle studio blank screen
11 replies
DTDrizzle Team
Created by adrtivv on 11/27/2023 in #help
drizzle studio blank screen
11 replies
DTDrizzle Team
Created by adrtivv on 11/27/2023 in #help
drizzle studio blank screen
postgresql://username:password@localhost:5432/postgres_db?search_path=schemaOne
postgresql://username:password@localhost:5432/postgres_db?search_path=schemaOne
11 replies
DTDrizzle Team
Created by adrtivv on 11/27/2023 in #help
drizzle studio blank screen
I'm using a local database btw, booted up in a podman container and yeah it does work with the drizzle client so I don't think the config has any issue.
11 replies
DTDrizzle Team
Created by adrtivv on 11/27/2023 in #help
drizzle studio blank screen
// dotenv required for `drizzle-studio push:pg`
import dotenv from "dotenv";
dotenv.config();
import type { Config } from "drizzle-kit";

export default {
driver: "pg",
dbCredentials: {
connectionString: process.env.DATABASE_URL!,
},
out: "./migrations",
schema: "./src/db/schema.ts",
// this field needed when using `drizzle-studio push:pg` dunno why
schemaFilter: "schemaOne",
} satisfies Config;
// dotenv required for `drizzle-studio push:pg`
import dotenv from "dotenv";
dotenv.config();
import type { Config } from "drizzle-kit";

export default {
driver: "pg",
dbCredentials: {
connectionString: process.env.DATABASE_URL!,
},
out: "./migrations",
schema: "./src/db/schema.ts",
// this field needed when using `drizzle-studio push:pg` dunno why
schemaFilter: "schemaOne",
} satisfies Config;
11 replies