Skip to content
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

Add prisma #38

Closed
wants to merge 6 commits into from
Closed

Add prisma #38

wants to merge 6 commits into from

Conversation

G3root
Copy link
Contributor

@G3root G3root commented Nov 15, 2021

What does it do?

adds prisma as an ORM

Any helpful background information?

this is a Draft PR to adapt prisma as an ORM.
for more info check #25

task list

  • schema migrations from plain sql to prisma schema
  • code review from maintainers
  • add seeding scripts
  • finalize

Does it close any issues?

This closes #25

To Test locally

  1. set DATABASE_URL environment variable
DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"
  1. run yarn generate to generate types
  2. run yarn studio to manipulate data in a GUI

@vercel
Copy link

vercel bot commented Nov 15, 2021

@G3root is attempting to deploy a commit to the Developerdao Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@carlomigueldy carlomigueldy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome @G3root thank you! I'm going to check this soon in my machine locally. I'll get back at this!

@G3root
Copy link
Contributor Author

G3root commented Nov 15, 2021

This looks awesome @G3root thank you! I'm going to check this soon in my machine locally. I'll get back at this!

This sounds promising https://cloud.prisma.io/ .
what's your thought ?

Copy link
Contributor

@carlomigueldy carlomigueldy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm finally able to review it thoroughly, had a lot of things prioritized so was not really able to give a full review. And with that I have some requested changes too.

Thank you once again, it does look awesome!

Let's prefer rename the Prisma models to be singular than them being plural:

  • model Users -> model User
  • model Gigs -> model Gig

But are we able to override the table names? (e.g. If we have model User singular, then when it gets migrated its table name would be users). Or would Prisma automatically transform singular models into plural lower-cased table names? (The very similar thing on how Laravel does it or other frameworks that uses a similar approach)

Also when you start changing those status attributes to use an Enum, then the default values should be DRAFT for the most of it.

The cuid() is awesome and it looks like Firestore document IDs. Previously I think they used uuids but looks like cuid is more of an improved version. So that's nice to learn about it from this PR :) @G3root

deletedAt DateTime? //optional field
users UserKeyword[]
jobs JobKeyword[]
keywords GigKeyword[]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be gigs GigKeyword[]?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh by the way just noticed, my mistake. This regard this comment @G3root

client/prisma/schema.prisma Show resolved Hide resolved
client/prisma/schema.prisma Show resolved Hide resolved
client/prisma/schema.prisma Show resolved Hide resolved
client/prisma/schema.prisma Show resolved Hide resolved
client/prisma/schema.prisma Show resolved Hide resolved
client/prisma/schema.prisma Show resolved Hide resolved
client/prisma/schema.prisma Show resolved Hide resolved
client/prisma/schema.prisma Show resolved Hide resolved
client/package.json Show resolved Hide resolved
@carlomigueldy
Copy link
Contributor

This sounds promising https://cloud.prisma.io/ .
what's your thought ?

It looks awesome, I also want to give it a try and explore more about it. Would be interesting to know what it offers 👀

@G3root
Copy link
Contributor Author

G3root commented Nov 16, 2021

thanks for the thorough review @carlomigueldy, i'll ship those changes today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: using prisma for database query.
2 participants