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

Database set up with Drizzle #1

Merged
merged 1 commit into from
Jul 26, 2024
Merged

Database set up with Drizzle #1

merged 1 commit into from
Jul 26, 2024

Conversation

carletex
Copy link
Contributor

The idea of this PR is to have the end-to-end skeleton for everything related to the Database. We will need to tweak a bunch of things as we go, but this can serve as a good starting point.

  • We are using Drizzle (Typescript ORM) & Drizzle kit (cli)
  • We are using the pg driver (Postgres). There is also a Vercel pg connector.. not sure what the benefits are, but sticking with just pg that will work for our local docker + vercel.
  • Adding a docker-compose file to easily spin up a local Postgres database
  • Database config can be found in services/database/config. Current schema is just a test.
  • Went with the repository pattern as a way of abstracting of the data layer on the database (e.g. services/database/repositories/submissions.ts)
  • drizzle.config.ts is for drizzle-kit (push, migrate, etc). See readme for more info. Since it's not boostraped by NextJS, we need to manually add the .env.vars
  • For now, created .env.development with required data. You can override it with .env.local (except in the cases where we are loading .env.development directly).
  • Create a seed.ts file. See README for more info.
  • yarn drizzle-kit studio for a nice UI
  • Created a couple of (temporary) API route to test (we can remove them whenever)
    • I like the API routes in general, but in some cases we can do server components directly (not a fan of nextjs server actions sometimes tho)
  • Added some (database) instructions in the Readme

I think next steps could be to start creating some of the workflows (hackathon registration, submit project, admin view/vote, etc) that use the database, so we can iterate on the schema as we go.

@carletex carletex requested review from portdeveloper and damianmarti and removed request for portdeveloper July 26, 2024 09:20
Copy link
Member

@damianmarti damianmarti left a comment

Choose a reason for hiding this comment

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

@carletex everything looks great! Only a small comment.

@damianmarti damianmarti merged commit 3fe95d4 into main Jul 26, 2024
1 check passed
@damianmarti damianmarti deleted the database branch July 26, 2024 14:03
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.

2 participants