Drizzle Kit studio error

When I visit studio page, it keeps showing the spinner and the console has There is not enough information to infer relation "__public__.users_table.sessions_tables_user_id" error. my schema:
export const appSchema = pgSchema(process.env.SECURE_DB_SCHEMA);

export const userTable = pgTable('users_table', {
id: text('id').notNull().primaryKey(),
name: text('name').notNull(),
email: text('email').notNull().unique(),
password_hash: text('password_hash').notNull()
});

export const sessionTable = appSchema.table('sessions_table', {
id: text('id').primaryKey(),
userId: text('user_id')
.notNull()
.references(() => userTable.id),
expiresAt: timestamp('expires_at', {
withTimezone: true,
mode: 'date'
}).notNull()
});
export const appSchema = pgSchema(process.env.SECURE_DB_SCHEMA);

export const userTable = pgTable('users_table', {
id: text('id').notNull().primaryKey(),
name: text('name').notNull(),
email: text('email').notNull().unique(),
password_hash: text('password_hash').notNull()
});

export const sessionTable = appSchema.table('sessions_table', {
id: text('id').primaryKey(),
userId: text('user_id')
.notNull()
.references(() => userTable.id),
expiresAt: timestamp('expires_at', {
withTimezone: true,
mode: 'date'
}).notNull()
});
1 Reply
Shiba Bop
Shiba BopOP7mo ago
ok so the reason it was happening, I had sessionTable defined on different schemas, and drizzle-kit studio didnt know what to do with 2 matching tables even though they are on different schemas
Want results from more Discord servers?
Add your server