Key columns "user_id" and "id" are of incompatible types: text and bigint.

I'm getting the error in the title ^ but they're the same type.
export const usersTable = pgTable('users', {
id: text('id').primaryKey()
});

export const likedCollectionsTable = pgTable('liked_collections', {
userId: text('user_id').references(() => usersTable.id),
collection_id: integer('collection_id').references(() => collectionsTable.id)
});

export const recommendedCollectionsTable = pgTable('recommended_collections', {
userId: text('user_id').references(() => usersTable.id),
collection_id: integer('collection_id').references(() => collectionsTable.id)
});
export const usersTable = pgTable('users', {
id: text('id').primaryKey()
});

export const likedCollectionsTable = pgTable('liked_collections', {
userId: text('user_id').references(() => usersTable.id),
collection_id: integer('collection_id').references(() => collectionsTable.id)
});

export const recommendedCollectionsTable = pgTable('recommended_collections', {
userId: text('user_id').references(() => usersTable.id),
collection_id: integer('collection_id').references(() => collectionsTable.id)
});
2 Replies
paaradiso
paaradisoOP14mo ago
there's not even a bigint anywhere in my code solved. i just dropped the table and re-migrated and it works can i change the type when migrating?
Angelelz
Angelelz14mo ago
You can change the type, but run a migration immediately, because we don't know if the statements will be in the correct order if you make several changes Your problem was very likely related to several changes that you made to your schema, and when you generated your migration, the type change was picked up but the statement was put after some statements that depended on that type change
Want results from more Discord servers?
Add your server