Andrey Los
Andrey Los
DTDrizzle Team
Created by Andrey Los on 8/24/2023 in #help
It is possible to stop notice logs from appearing?
Hi there. So I'm using postgres and I run execute with table truncate. No matter what I try I always get some stuff spammed into the console. Same applies for migration scripts. Overriding logger or writer doesn't help in this case. Thanks
11 replies
DTDrizzle Team
Created by Andrey Los on 8/8/2023 in #help
There is not enough information to infer relation. What am I doing wrong?
I have such a setup yet I'm getting There is not enough information to infer relation "users.organizations". What am I missing? (below are all my relations) It's a many-to-many relationship. I also registered all that stuff into the schema (below)
await db.query.users.findFirst({
where: eq(users.id, user.id),
with: { organizations: true },
})
await db.query.users.findFirst({
where: eq(users.id, user.id),
with: { organizations: true },
})
import { relations } from "drizzle-orm"
import { pgTable, primaryKey, uuid } from "drizzle-orm/pg-core"

import { organizations } from "./organizations"
import { users } from "./user"

export const usersToOrganizations = pgTable(
"usersToOrganizations",
{
userId: uuid("userId")
.notNull()
.references(() => users.id),
organizationId: uuid("organizationId")
.notNull()
.references(() => organizations.id),
},
(t) => ({
pk: primaryKey(t.userId, t.organizationId),
}),
)

export const usersToOrganizationsRelations = relations(
usersToOrganizations,
({ one }) => ({
organization: one(organizations, {
fields: [usersToOrganizations.organizationId],
references: [organizations.id],
}),
user: one(users, {
fields: [usersToOrganizations.userId],
references: [users.id],
}),
}),
)

export const usersRelations = relations(users, ({ many }) => ({
organizations: many(organizations),
}))

export const organizationsRelations = relations(organizations, ({ many }) => ({
users: many(users),
}))
import { relations } from "drizzle-orm"
import { pgTable, primaryKey, uuid } from "drizzle-orm/pg-core"

import { organizations } from "./organizations"
import { users } from "./user"

export const usersToOrganizations = pgTable(
"usersToOrganizations",
{
userId: uuid("userId")
.notNull()
.references(() => users.id),
organizationId: uuid("organizationId")
.notNull()
.references(() => organizations.id),
},
(t) => ({
pk: primaryKey(t.userId, t.organizationId),
}),
)

export const usersToOrganizationsRelations = relations(
usersToOrganizations,
({ one }) => ({
organization: one(organizations, {
fields: [usersToOrganizations.organizationId],
references: [organizations.id],
}),
user: one(users, {
fields: [usersToOrganizations.userId],
references: [users.id],
}),
}),
)

export const usersRelations = relations(users, ({ many }) => ({
organizations: many(organizations),
}))

export const organizationsRelations = relations(organizations, ({ many }) => ({
users: many(users),
}))
export const db = drizzle(queryClient, {
logger: new DrizzleLogger(),
schema: {
users,
organizations,
identities,
usersToOrganizations,
identitiesRelations,
organizationsRelations,
usersToOrganizationsRelations,
usersRelations,
},
})
export const db = drizzle(queryClient, {
logger: new DrizzleLogger(),
schema: {
users,
organizations,
identities,
usersToOrganizations,
identitiesRelations,
organizationsRelations,
usersToOrganizationsRelations,
usersRelations,
},
})
11 replies