rbravo
rbravo
Explore posts from servers
DTDrizzle Team
Created by rbravo on 1/30/2024 in #help
Postgresql Foreign Key doesn't accept a name config param?
No description
1 replies
DTDrizzle Team
Created by rbravo on 1/19/2024 in #help
Error: There is not enough information to infer relation
Hey, I'm trying to convert a Prisma schema to Drizzle. Here's the schema:
export const messages = mysqlTable(
"Message",
{
id: varchar("id", { length: 256 }).primaryKey(),
whatsappId: varchar("whatsappId", { length: 256 }).unique(),
messageFrom: varchar("messageFrom", { length: 256 }),
messageTo: varchar("messageTo", { length: 256 }),
content: text("content"),
createdAt: timestamp("createdAt")
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
replyToId: bigint("replyToId", { mode: "number" }),
type: MessageType.default("textMessage"),
mediaId: varchar("mediaId", { length: 256 }),
caption: text("caption"),
conversationId: bigint("conversationId", { mode: "number" }),
userId: varchar("userId", { length: 256 }),
status: MessageStatus.default("SENT"),
deliveredAt: timestamp("deliveredAt"),
readAt: timestamp("readAt"),
forwarded: boolean("forwarded"),
address: text("address"),
latitude: varchar("latitude", { length: 256 }),
longitude: varchar("longitude", { length: 256 }),
name: text("name"),
url: text("url"),
voice: boolean("voice"),
fileType: text("fileType"),
fileName: text("fileName"),
contactName: text("contactName"),
contactPhone: varchar("contactPhone", { length: 256 }),
},
(table) => {
return {
whatsappIdIdx: index("whatsappId_idx").on(table.whatsappId),
replyToIdIdx: index("replyToId_idx").on(table.replyToId),
conversationIdIdx: index("conversationId_idx").on(table.conversationId),
userIdIdx: index("userId_idx").on(table.userId),
messageIdIdx: index("messageId_idx").on(
table.messageFrom,
table.messageTo,
table.createdAt,
),
};
},
);
export const messages = mysqlTable(
"Message",
{
id: varchar("id", { length: 256 }).primaryKey(),
whatsappId: varchar("whatsappId", { length: 256 }).unique(),
messageFrom: varchar("messageFrom", { length: 256 }),
messageTo: varchar("messageTo", { length: 256 }),
content: text("content"),
createdAt: timestamp("createdAt")
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
replyToId: bigint("replyToId", { mode: "number" }),
type: MessageType.default("textMessage"),
mediaId: varchar("mediaId", { length: 256 }),
caption: text("caption"),
conversationId: bigint("conversationId", { mode: "number" }),
userId: varchar("userId", { length: 256 }),
status: MessageStatus.default("SENT"),
deliveredAt: timestamp("deliveredAt"),
readAt: timestamp("readAt"),
forwarded: boolean("forwarded"),
address: text("address"),
latitude: varchar("latitude", { length: 256 }),
longitude: varchar("longitude", { length: 256 }),
name: text("name"),
url: text("url"),
voice: boolean("voice"),
fileType: text("fileType"),
fileName: text("fileName"),
contactName: text("contactName"),
contactPhone: varchar("contactPhone", { length: 256 }),
},
(table) => {
return {
whatsappIdIdx: index("whatsappId_idx").on(table.whatsappId),
replyToIdIdx: index("replyToId_idx").on(table.replyToId),
conversationIdIdx: index("conversationId_idx").on(table.conversationId),
userIdIdx: index("userId_idx").on(table.userId),
messageIdIdx: index("messageId_idx").on(
table.messageFrom,
table.messageTo,
table.createdAt,
),
};
},
);
When I try to run drizzle-kit studio I get this error: "rror: There is not enough information to infer relation "public.messages.replies" at normalizeRelation" Am I doing something wrong here?
38 replies
RRailway
Created by rbravo on 9/9/2023 in #✋|help
How to connect FastAPI with Planetscale (mysqlclient error)
Hey, how are you guys doing? I have a backend on Railway who is running with FastAPI (using this template https://railway.app/template/-NvLj4). I'm also using planetscale, which requires me to have mysqlclient as a dependency. The problem is that when the app is building I'm getting the error attached. Does anyone know how can I fix this?
12 replies