TypeError: Cannot read properties of undefined (reading 'compositePrimaryKeys')

I'm getting this error when I want to rename a table (there are no other changes). Old table:
export const userFavoritesMusics = pgTable(
'user_favorites',
{
userId: text('user_id')
.notNull()
.references(() => users.id, { onDelete: 'cascade' }),
musicId: integer('music_id')
.notNull()
.references(() => musics.id, { onDelete: 'cascade' }),
createdAt: timestamp('created_at').notNull().defaultNow(),
},
(t) => ({
pk: primaryKey(t.userId, t.musicId),
}),
);
export const userFavoritesMusics = pgTable(
'user_favorites',
{
userId: text('user_id')
.notNull()
.references(() => users.id, { onDelete: 'cascade' }),
musicId: integer('music_id')
.notNull()
.references(() => musics.id, { onDelete: 'cascade' }),
createdAt: timestamp('created_at').notNull().defaultNow(),
},
(t) => ({
pk: primaryKey(t.userId, t.musicId),
}),
);
New table:
export const userFavoritesMusics = pgTable(
'user_favorites_musics',
{
userId: text('user_id')
.notNull()
.references(() => users.id, { onDelete: 'cascade' }),
musicId: integer('music_id')
.notNull()
.references(() => musics.id, { onDelete: 'cascade' }),
createdAt: timestamp('created_at').notNull().defaultNow(),
},
(t) => ({
pk: primaryKey(t.userId, t.musicId),
}),
);
export const userFavoritesMusics = pgTable(
'user_favorites_musics',
{
userId: text('user_id')
.notNull()
.references(() => users.id, { onDelete: 'cascade' }),
musicId: integer('music_id')
.notNull()
.references(() => musics.id, { onDelete: 'cascade' }),
createdAt: timestamp('created_at').notNull().defaultNow(),
},
(t) => ({
pk: primaryKey(t.userId, t.musicId),
}),
);
Only the name changed so I don't understand why I'm getting this error. What should I do ?
2 Replies
Christoph
Christoph9mo ago
on what function call do you get the error? when creating the drizzle instance or when doing a query?
Tibo
TiboOP9mo ago
When I do a push
Want results from more Discord servers?
Add your server