-
Notifications
You must be signed in to change notification settings - Fork 796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(drizzle): Migrate to Drizzle ORM #404
Conversation
@realmikesolo is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great!
app/[domain]/[slug]/page.tsx
Outdated
@@ -113,7 +109,7 @@ export default async function SitePostPage({ | |||
href={ | |||
data.site?.user?.username | |||
? `https://twitter.com/${data.site.user.username}` | |||
: `https://github.com/${data.site?.user?.gh_username}` | |||
: `https://github.com/${data.site?.user?.ghUsername}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this require a data migration?
lib/actions.ts
Outdated
}) | ||
.returning(); | ||
|
||
// unnecessary await |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the await?
lib/actions.ts
Outdated
.where(eq(sites.id, site.id)) | ||
.returning(); | ||
|
||
await revalidateTag( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await revalidateTag( | |
revalidateTag( |
lib/actions.ts
Outdated
`${site.subdomain}.${process.env.NEXT_PUBLIC_ROOT_DOMAIN}-metadata`, | ||
); | ||
response.customDomain && | ||
(await revalidateTag(`${site.customDomain}-metadata`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(await revalidateTag(`${site.customDomain}-metadata`)); | |
revalidateTag(`${site.customDomain}-metadata`); |
lib/actions.ts
Outdated
}) | ||
.returning(); | ||
|
||
await revalidateTag( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await revalidateTag( | |
revalidateTag( |
It's an interesting choice to move away from a project that enterprises and governments support to one that's unknown and may require security reviews. What benefits make this worth it? |
@m-torin if you would like to use Prisma, that's great. Please do! I don't have anything against Prisma. In fact, we just worked with them on this https://db-latency.vercel.app/. |
I made some edits based on the review, updated the Currently, there are two bugs related to Please let me know if anything needs updating. |
app/[domain]/[slug]/page.tsx
Outdated
import { getPostData, getSiteData } from "@/lib/fetchers"; | ||
import BlogCard from "@/components/blog-card"; | ||
import BlurImage from "@/components/blur-image"; | ||
import MDX from "@/components/mdx"; | ||
import { placeholderBlurhash, toDateString } from "@/lib/utils"; | ||
import db from "@/lib/db/db"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inline
components/posts.tsx
Outdated
|
||
return posts.length > 0 ? ( | ||
const query = db |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make in query syntax
components/sites.tsx
Outdated
}); | ||
const query = db | ||
.select({ | ||
...getTableColumns(sites), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant
Bugs with Drizzle-kit were fixed |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected], npm/[email protected] |
🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎ To accept the risk, merge this PR and you will not be notified again.
Next stepsWhat do I need to know about license files?(Experimental) A license not known to be considered permissive was found Determine whether use of material not offered under a known permissive license works for you What do I need to know about license files?(Experimental) Copyleft license information was found Determine whether use of copyleft material works for you Take a deeper look at the dependencyTake a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev. Remove the packageIf you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency. Mark a package as acceptable riskTo ignore an alert, reply with a comment starting with
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@leerob @realmikesolo - this seems to break Github auth as it might happen that Github login that's in the example returns null for the email, due to the schema email field being set to notNull in users table. This happens when the person trying to login in Github email preferences has Keep my email addresses private checked. |
Submitted issue for tracking: #412 |
@mdichtler we're a bit confused with @realmikesolo as of now, since originally Prisma's adapter did have this field as just unique, then the Next Auth author mentioned that field(we might've got it wrong) can be |
@AlexBlokh - I'm free for the next hour if you want to troubleshoot this a bit - add my discord: @MartinDichtler also attaching screenshot of my github profile where email is set to null. This is logged from auth.ts line 14 (profile callback) |
@mdichtler here's a conversation with the NextAuth team in Discord They advise us to do a migration of |
This PR was made to migrate from Prisma to Drizzle ORM. It involves rewriting the database interactions using
Drizzle ORM
.Instructions
If you directly start the project with Drizzle ORM
lib/legacy-schema.ts
file as it is only used when migrating from Prisma.lib/schema.ts
will be used for database queries.drizzle-kit push
command to apply your changes to the database. Learn more about the push command here.If you migrating from Prisma
lib/schema.ts
file and renamelib/legacy-schema.ts
tolib/schema.ts
.email
column inusers
table is set tonot null
to ensure compatibility with drizzle next-auth adapter. Apply this change by running thedrizzle-kit push
command. Learn more aboutpush
command here.