nu
nu
DTDrizzle Team
Created by nu on 2/13/2025 in #help
How to handle multiple unique constraints with onConflictDoUpdate?
My postgres table has 2 unique constraints:
unique("unique_game").on(table.idTeamHome, table.idTeamAway, table.time),
unique("unique_id").on(table.idEvent),

unique("unique_game").on(table.idTeamHome, table.idTeamAway, table.time),
unique("unique_id").on(table.idEvent),

During insert I am able to handle unique_id constraint, but how do I handle the other one?
.onConflictDoUpdate({
target: games.idEvent,
set: {
time: sql.raw(`excluded."${games.time.name}"`),
idEvent: sql.raw(`excluded."${games.idEvent.name}"`),
},
.onConflictDoUpdate({
target: games.idEvent,
set: {
time: sql.raw(`excluded."${games.time.name}"`),
idEvent: sql.raw(`excluded."${games.idEvent.name}"`),
},
5 replies
DTDrizzle Team
Created by nu on 2/5/2025 in #help
Changing postgres timestamp mode (string -> date) isn't reflected in migrations
Hi. I have my migrations generated and applied from my initial schema. Now in the schema I changed to mode: 'date' in multiple timestamp columns (ex: time: timestamp({ withTimezone: true, mode: 'date' }).notNull(),). This was mode: 'string' by default previously. Now when I run the drizzle-kit generate command, no migrations are generated. I made this change to multiple columns. Is this a bug or is it expected behaviour?
4 replies
DTDrizzle Team
Created by nu on 12/7/2024 in #help
How to add comment on postgres table columns (and other one-time operations like add trigger)
I want to add comment on columns of my postgres table (COMMENT ON COLUMN). There is no native function in drizzle. I can see suggestions like
export default {
async up(db) {
await db.execute(sql`COMMENT ON COLUMN users.username IS 'User\'s unique username';`);
await db.execute(sql`COMMENT ON COLUMN users.email IS 'User\'s email address';`);
},
export default {
async up(db) {
await db.execute(sql`COMMENT ON COLUMN users.username IS 'User\'s unique username';`);
await db.execute(sql`COMMENT ON COLUMN users.email IS 'User\'s email address';`);
},
But won't this be executed every time? I faced same doubt when trying to add trigger+function.
4 replies