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)
});
paaradiso
paaradiso192d 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
Angelelz192d 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
More Posts
Migration Failed LibsqlErrorI had migrated prior, done a lot of schema work, and then did a drizzle-generate, worked fine and I[Solved] cannot find package 'mysql2'I've setup drizzle with a planetscale db and pushed a simple user schema, however running the pnpm dError: this.client.prepare is not a functionI am trying to build a project using Bun, Hono and Drizzle. When i am starting the project with thispg: introspect failsSo I have some tables that do not have a primary key constraint (by design) and it seems that drizzlclient connection refusedI'm using bun. I was able to get the pool connection working, but the same connection configuratioRunning migrations in server-less (edge) land??According to the docs: ``` // this will automatically run needed migrations on the database await mIs there any way to call drizzle-kit with the new node --env-file=.env argument?Hey, since node supports env files since pretty recently, it would be nice if we could ditch dotenv.enumerating tablesI have a table of possible 'statuses' for a column in my records table and would like my zod schema how to group Related Items```typescript // index.ts const coursesList = await db .select({ title: courses.title, tags: tagsNested where filter, how to not include emptyThe following almost works ``` const query = db.query.productionItem.findMany({ with: { itemStis placeholder in prepare statements deprecated!??```typescript const courses = db.query.userCourses .findMany({ where: eq(placeholder("userId")SQLite json_eachHi. I wandted to use the json_each function in sqlite, but I dont think the query is building correc