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

Schema for Inventory #9

Open
16 tasks
idil-bit opened this issue Oct 20, 2024 · 0 comments
Open
16 tasks

Schema for Inventory #9

idil-bit opened this issue Oct 20, 2024 · 0 comments
Assignees
Labels

Comments

@idil-bit
Copy link
Collaborator

idil-bit commented Oct 20, 2024

Purpose

You'll be creating the schemas for one of the big databases our client will be using: inventory!

TODO

Initial steps:

  • move this ticket to the In Progress column
  • get updated with the codebase (git checkout dev, git pull, create a new branch by git checkout -b [branchname] as per README, npm install to update your dependencies, npm run dev)

Prisma setup:

  • Add a model to the schema.prisma file for inventory (itemName is a primary key (unique identifier))
  • Generate the Prisma client by running: npx prisma generate
  • Testing (after making the Prisma schema)
    • prisma migrate dev (this applies updates the neon.tech db with your new prisma changes)
    • prisma db pull (this tests if Prisma can connect to the Neon.tech database)
    • ts-node testConnection.ts (runs the connection test under tests/testConnection.ts)

API setup:

  • Open the file called api/inventory/route.ts
  • Add CRUD functions for inventory (not API endpoints yet, but utility functions that will be used in the API)
    • Create (POST)
    • Read (GET)
    • Update (PUT)
    • Delete (DELETE)
  • create a PR for this ticket
  • move this ticket to the Ready for Review column

What is CRUD?
Create: Takes all the information necessary to create an object
Read all: Returns every record in the table
Update: Takes a record object with an ID. Writes over the existing record with the input
Delete: Deletes a record from the table, given a record ID

Helpful Resources

We'll be using Vercel for the server: https://vercel.com/guides/nextjs-prisma-postgres

How do we access our database?
We're using Neon.tech to host and manage our SQL database. Running the prisma migrate dev command applies any pending migration files in our Prisma project to our Neon.tech PostgreSQL database. This means it creates new tables or modifies existing ones based on the changes in the Prisma schema. These changes are reflected in the Neon.tech dashboard. You'll be able to see the newly created tables, columns, and relationships in your database, or any modifications (like added or removed columns) if you're updating the schema.

Our schema

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Progress
Development

No branches or pull requests

3 participants