philbookst
philbookst
Explore posts from servers
CDCloudflare Developers
Created by philbookst on 5/3/2024 in #pages-help
Production branch deploys are being skipped after retrying a deployment manually
Hey I recently had to retry a deploy manually, since then all pushes to my repo are being skipped by my pages build pipeline. It gives me a warning that I need to change my build settings, but everything looks good there. What do I need to do to re-enable it? Thanks!
1 replies
DTDrizzle Team
Created by philbookst on 12/20/2023 in #help
push:sqlite error _old_push table with turso
is there any known workaround for this issue: https://github.com/drizzle-team/drizzle-orm/issues/1313 adding a column to a table and calling db:push gives a 500 error due to a _oldpushtablename being created causing some issues
6 replies
CDCloudflare Developers
Created by philbookst on 6/26/2023 in #pages-help
Issue re-adding deleted custom domain
I've tried adding a custom domain again after deleting it and i got the following error:
You have already added this custom domain. Select another custom domain or check your project configuration.
You have already added this custom domain. Select another custom domain or check your project configuration.
Any idea on how to fix this? I've checked the custom domains panel and the domain is not listed there
3 replies
DTDrizzle Team
Created by philbookst on 6/7/2023 in #help
Query/select statement of column via sql`` for extras field
is it possible to make a normal select to another table inside a extras object in a relational query? i'm trying to do something like this:
const lessonWithComments = await db.query.Lesson.findFirst({
where: eq(Lesson.id, lessonId),
with: {
comments: {
with: {
reactions: true,
user: {
columns: {
id: true,
title: true,
firstName: true,
lastName: true,
image: true
},
extras: {
memberKind: sql`
SELECT ${MemberOnCourse.memberKind}
FROM ${MemberOnCourse}
WHERE ${MemberOnCourse.userId} = ${User.id}
`.as("memberKind")
}
}
}
}
},
orderBy: (Comment, { asc }) => [asc(Comment.createdAt)]
});
const lessonWithComments = await db.query.Lesson.findFirst({
where: eq(Lesson.id, lessonId),
with: {
comments: {
with: {
reactions: true,
user: {
columns: {
id: true,
title: true,
firstName: true,
lastName: true,
image: true
},
extras: {
memberKind: sql`
SELECT ${MemberOnCourse.memberKind}
FROM ${MemberOnCourse}
WHERE ${MemberOnCourse.userId} = ${User.id}
`.as("memberKind")
}
}
}
}
},
orderBy: (Comment, { asc }) => [asc(Comment.createdAt)]
});
i'm getting a syntax error at position 2270 near 'SELECT' is this possible or should i just add the necessary relation and query it on the same level as the user object?
2 replies
DTDrizzle Team
Created by philbookst on 6/2/2023 in #help
Problem with infering json type in zod schema
When using the following table/schema:
const Test = mysqlTable(
"Test",
{
id: serial("id").primaryKey().notNull(),
value: json("value").$type<{ a: string, b: number }>().notNull()
},
)

const TestInsertSchema = createInsertSchema(Test)

const ValueFromSchema = TestInsertSchema.pick({
value: true
})

type Value = z.infer<typeof ValueFromSchema>
// Value is typed as following:
// type Value = {
// value: ((string | number | boolean | {
// [key: string]: Json;
// } | Json[]) & (string | number | boolean | {
// [key: string]: Json;
// } | Json[] | undefined)) | null;
// }
const Test = mysqlTable(
"Test",
{
id: serial("id").primaryKey().notNull(),
value: json("value").$type<{ a: string, b: number }>().notNull()
},
)

const TestInsertSchema = createInsertSchema(Test)

const ValueFromSchema = TestInsertSchema.pick({
value: true
})

type Value = z.infer<typeof ValueFromSchema>
// Value is typed as following:
// type Value = {
// value: ((string | number | boolean | {
// [key: string]: Json;
// } | Json[]) & (string | number | boolean | {
// [key: string]: Json;
// } | Json[] | undefined)) | null;
// }
Am I doing something wrong? How can I pick the value key with correct types from the schema?
3 replies
DTDrizzle Team
Created by philbookst on 5/30/2023 in #help
Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020
Hey I just upgraded to the v^0.26.2 and I get the following error:
Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)

node_modules/.pnpm/drizzle-orm@0.26.2_@cloudflare+workers-types@4.20230518.0_@opentelemetry+api@1.4.1_@planetscale+database@1.7.0/node_modules/drizzle-orm/relations-d3070559.mjs:301:11:
301 │ otel = await import('@opentelemetry/api');
╵ ~~~~~
Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)

node_modules/.pnpm/drizzle-orm@0.26.2_@cloudflare+workers-types@4.20230518.0_@opentelemetry+api@1.4.1_@planetscale+database@1.7.0/node_modules/drizzle-orm/relations-d3070559.mjs:301:11:
301 │ otel = await import('@opentelemetry/api');
╵ ~~~~~
this breaks my local development and (sveltekit) build as well
2 replies
CDCloudflare Developers
Created by philbookst on 5/18/2023 in #pages-help
Error 522 when trying to setup a vanity domain via cf for saas
Hey I'm trying to setup vanity domains for my pages project, so that customers can use their own domain instead of a subdomain of my domain. I've added a custom domain in the SSL cf for saas panel (screenshot) but accessing this domain gives me a 522 error. How can I fix this? I've added the CNAME on the vanity domain to point to my fallback origin configured in the cf for saas panel
11 replies
CDCloudflare Developers
Created by philbookst on 5/17/2023 in #general-help
CF for saas hostname _acme-challenge not validating
Hey I'm trying to setup custom vanity domains for my pages project but the they are stuck in a pending validation state. I've tried with 2 domains, validating the _acme-challenge record fails, but the _cf-custom-hostname record succeeds.
2 replies
DTDrizzle Team
Created by philbookst on 5/11/2023 in #help
uuid missing in drizzle-orm/mysql-core?
There is a uuid method in the drizzle-orm/pg-core package, but none in the mysql-core package. What is the reason behind this? What should we use instead to generate uuids automatically?
12 replies
DTDrizzle Team
Created by philbookst on 5/11/2023 in #help
DatabaseError: Duplicate column name 'id'
hey guys, i have a problem in my query but cannot figure out what is causing it.
const coursesSq = db
.select({
id: Course.id,
name: Course.name,
image: Course.image,
status: Course.status,
description: Course.description,
guides: Course.guides,
price: Course.price,
moduleCount: sql<number>`COUNT(${Module.id})`.as("moduleCount")
})
.from(Course)
.leftJoin(Module, eq(Course.id, Module.courseId))
.groupBy(Course.id)
.as("courses");

const membersOnCourse = db
.select({
memberId: MemberOnCourse.id,
courseId: MemberOnCourse.courseId,
memberKind: MemberOnCourse.memberKind,
user: {
id: User.id,
title: User.title,
firstName: User.firstName,
lastName: User.lastName,
image: User.image
}
})
.from(MemberOnCourse)
.innerJoin(User, eq(MemberOnCourse.userId, User.id))
.as("membersOnCourse");

const courses = await db
.select()
.from(coursesSq)
.leftJoin(membersOnCourse, eq(coursesSq.id, membersOnCourse.courseId));
const coursesSq = db
.select({
id: Course.id,
name: Course.name,
image: Course.image,
status: Course.status,
description: Course.description,
guides: Course.guides,
price: Course.price,
moduleCount: sql<number>`COUNT(${Module.id})`.as("moduleCount")
})
.from(Course)
.leftJoin(Module, eq(Course.id, Module.courseId))
.groupBy(Course.id)
.as("courses");

const membersOnCourse = db
.select({
memberId: MemberOnCourse.id,
courseId: MemberOnCourse.courseId,
memberKind: MemberOnCourse.memberKind,
user: {
id: User.id,
title: User.title,
firstName: User.firstName,
lastName: User.lastName,
image: User.image
}
})
.from(MemberOnCourse)
.innerJoin(User, eq(MemberOnCourse.userId, User.id))
.as("membersOnCourse");

const courses = await db
.select()
.from(coursesSq)
.leftJoin(membersOnCourse, eq(coursesSq.id, membersOnCourse.courseId));
any idea what's going on?
5 replies
DTDrizzle Team
Created by philbookst on 5/11/2023 in #help
Need help transform a nested prisma query to drizzle
Hey I'm trying to translate the following prisma query to drizzle:
const invite = await prisma.invite.findUnique({
where: {
id: token
},
include: {
invitedBy: {
select: {
title: true,
firstName: true,
lastName: true,
}
},
course: {
select: {
name: true,
settings: {
select: {
hostAlias: true,
moderatorAlias: true,
memberAlias: true
}
}
}
}
}
});
const invite = await prisma.invite.findUnique({
where: {
id: token
},
include: {
invitedBy: {
select: {
title: true,
firstName: true,
lastName: true,
}
},
course: {
select: {
name: true,
settings: {
select: {
hostAlias: true,
moderatorAlias: true,
memberAlias: true
}
}
}
}
}
});
closest i've come to is this:
const invite = await db
.select({
inviteExpiresAt: Invite.inviteExpiresAt,
inviteAs: Invite.inviteAs,
limit: Invite.limit,
invitedBy: {
title: User.title,
firstName: User.firstName,
lastName: User.lastName,
},
course: {
id: Course.id,
name: Course.name,
},
settings: {
hostAlias: CourseSettings.hostAlias,
moderatorAlias: CourseSettings.moderatorAlias,
memberAlias: CourseSettings.memberAlias
}
})
.from(Invite)
.where(eq(Invite.id, token))
.innerJoin(User, eq(Invite.invitedById, User.id))
.innerJoin(Course, eq(Invite.courseId, Course.id))
.innerJoin(CourseSettings, eq(Course.id, CourseSettings.courseId))
const invite = await db
.select({
inviteExpiresAt: Invite.inviteExpiresAt,
inviteAs: Invite.inviteAs,
limit: Invite.limit,
invitedBy: {
title: User.title,
firstName: User.firstName,
lastName: User.lastName,
},
course: {
id: Course.id,
name: Course.name,
},
settings: {
hostAlias: CourseSettings.hostAlias,
moderatorAlias: CourseSettings.moderatorAlias,
memberAlias: CourseSettings.memberAlias
}
})
.from(Invite)
.where(eq(Invite.id, token))
.innerJoin(User, eq(Invite.invitedById, User.id))
.innerJoin(Course, eq(Invite.courseId, Course.id))
.innerJoin(CourseSettings, eq(Course.id, CourseSettings.courseId))
but when trying to move the settings object into the course object as it is in the prisma query I get an error Object literal may only specify known properties, and 'hostAlias' does not exist in type 'SQL<unknown> | Aliased<unknown> | AnyMySqlColumn<{}>' is there any way to get the same result with drizzle? thank you very much for your help! drizzle is awesome!
4 replies
CDCloudflare Developers
Created by philbookst on 2/16/2023 in #workers-help
How to create a trigger only for a specific environment?
I've tried deploying my wrangler.toml like this:
[env.production]
name = "workername-production"
[triggers]
crons = ["0 */2 * * *", "0 */6 * * *"]
[env.production]
name = "workername-production"
[triggers]
crons = ["0 */2 * * *", "0 */6 * * *"]
but it also deploys the trigger for my staging environment. Thanks for your help!
3 replies