-
Notifications
You must be signed in to change notification settings - Fork 2
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
Replace Kysely with Prisma for database interaction #1168
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
😱 |
This reverts commit 681c133.
@@ -57,13 +57,13 @@ const Landing: NextPage<{ user: User }> = ({ user }) => { | |||
<TextInput | |||
width="flex-1 mb-2 mx-1" | |||
placeholder="Fornavn" | |||
defaultValue={user.firstName} | |||
defaultValue={user.firstName ?? ""} |
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.
Questionable, should it not be ?? undefined
?
"@types/node": "^22.0.0", | ||
"@vitest/ui": "^1.3.1", | ||
"testcontainers": "^10.13.2", |
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.
Why was this removed?
return this.parseExtras(attendance) | ||
} | ||
|
||
// Prisma requires distinction between database null and json null, so here we choose database null |
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.
Use JSDoc comments if above function definition, or move into body for regular comment
return { ...data, extras: data.extras === null ? Prisma.DbNull : data.extras } | ||
} | ||
|
||
// Takes an object with unparsed JSON value yearCriteria and returns it with yearCriteria parsed |
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.
Same here
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.
Assume you merged this with job-listing-repository?
provider = "zod-prisma-types" | ||
output = "../src/generatedSchemas" | ||
|
||
useMultipleFiles = true |
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.
I would probably prefer to have all the codegen in a single file. It's less files to search through in text editors
longDescription String @default("") | ||
joinInfo String @default("") |
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 them nullable. Also why is joinInfo a different field? I think it should all just be one MDX blob
import { getProductFixtures } from "./fixtures/product" | ||
import { getProductPaymentProviderFixtures } from "./fixtures/product-payment-provider" | ||
|
||
if (process.env.DATABASE_URL === undefined) { |
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.
QOL: Add a if DATABASE_URL is pointing to AWS, then abort
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.
The generated schemas should not be commited to version control.
|
||
export { createMigrator } from "./migrator" | ||
const logger = getLogger("@dotkomonline/db") | ||
export * as dbSchemas from "./generatedSchemas" |
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.
I would prefer if it's just named schemas. I think it's quite unmistakenable what schemas we're talking about here
export * as dbSchemas from "./generatedSchemas" | |
export * as schemas from "./generatedSchemas" |
This pull request replaces Kysely with Prisma. This is done for a couple reasons:
Ref some points from earlier: #235
This is now possible, but I don't see why this is a big issue anyways, having a large file is fine.
We can wrap it, it works just fine
The Prisma team have rewritten the rust part of the codebase, so the large binaries shouldn't be a problem anymore.
This change drastically reduces the number of steps necessary to make minor changes by simply using
schema.prisma
as source of truth, and then generating migrations and domain object attributes based on those.Prisma is a very well maintained project, and is in my opinion well suited for monoweb.
The pull request is quite large and ugly because of all of the repository changes, those are most of the changes. The only non-trivial service change is job-listing-service which i refactored because the current solution was very much broken.