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

feat: !(Breaking) Implemented Prisma ORM and Initial Database Setup #138

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

kaali001
Copy link
Contributor

Description

This PR introduces the implementation of Prisma ORM for database management in the Drawn2Shoe project. The changes include integrating Prisma, setting up the initial database schema, and adding seed data.
This is Feat: #117 .

Changes

  1. Prisma Integration

    • Added Prisma and @prisma/client dependencies.
      Reason: To include Prisma ORM and its client library for database management and operations.

          "dependencies": {
           "prisma": "^3.0.0",
           "@prisma/client": "^3.0.0"
           }
      
      
  2. Database Schema setup

    • Created prisma/schema.prisma:
    • Reason: To define the database schema using Prisma's modeling language, ensuring a structured and scalable database
      design.
    • Created initial database schema including models for Mainuser, Product, Cart, Orders, Design, Designer, Retailer, Shoe, and
      Supplier.
  3. Database Seeding

    • Created prisma/seed.js:
    • Reason: To populate the database with initial values, facilitating development and testing with predefined data.
  4. Controllers Implementation

    • Modified the files in controllers folder which includes user.js, product.js, cart.js files for making query to database using
      Prisma.
  5. README Update

    Updated README.md:

    • Reason: To provide detailed setup instructions for Prisma, the database, and controllers, ensuring a smooth setup
      process for developers.

    • Changes: Added sections for Prisma setup, database seeding, and controllers:

How to test

  1. Clone the repository:

       git clone https://github.com/dvjsharma/Drawn2Shoe.git
       cd Drawn2Shoe
    
  2. Install dependencies:

    • Client:

         cd client
         npm install
      
    • Server:

       cd ../server
      npm install
      
      
  3. Set up the database:

    • Create a config.env file in the server directory and copy the contents from .env.example.
    • Add your MySQL database url in .env file (your user name and password).
    • Ensure your MySQL service is running and your database is named drawn2shoe.
  4. Run Prisma commands:

        cd server
        npx prisma migrate dev --name init
        npx prisma/db.seed
    
    
  5. Run the application:

    • Frontend:

              cd ../client
              npm run dev
      
    • Backend:

            cd ../server
            node server.js
      
  6. Verify the changes:

    • Ensure the application runs without errors.
    • Check the database to confirm the seeded data is correctly populated.
    • Test the CRUD operations to ensure Prisma ORM and controllers are functioning as expected.

Additional Notes

  • Ensure that the MySQL service is running before executing Prisma commands.

Checklist:

  • I have performed a self-review of my code
  • I have read and followed the Contribution Guidelines.
  • I have tested the changes thoroughly before submitting this pull request.
  • I have commented my code, particularly in hard-to-understand areas.

@kaali001 kaali001 changed the title Implemented Prisma ORM and Initial Database Setup feat: #117 Feat : Implemented Prisma ORM and Initial Database Setup feat: #117 Jul 13, 2024
@kaali001 kaali001 changed the title Feat : Implemented Prisma ORM and Initial Database Setup feat: #117 feat : Implemented Prisma ORM and Initial Database Setup feat: #117 Jul 13, 2024
@kaali001 kaali001 changed the title feat : Implemented Prisma ORM and Initial Database Setup feat: #117 feat: Implemented Prisma ORM and Initial Database Setup feat: #117 Jul 13, 2024
@dvjsharma
Copy link
Owner

Initial overview looks good @kaali001, will test over the weekend.

Copy link
Owner

@dvjsharma dvjsharma left a comment

Choose a reason for hiding this comment

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

LGTM

@dvjsharma
Copy link
Owner

Hey @kaali001, please squash the commits into 1 for merge.

@kaali001 kaali001 force-pushed the feature/automate-db-setup branch from 861bd3a to 92c2e1d Compare July 22, 2024 16:45
@kaali001
Copy link
Contributor Author

Hey @kaali001, please squash the commits into 1 for merge.

I have done it.

@kaali001
Copy link
Contributor Author

Hey @dcoder13 , please review it , I have two opened issues to work on.

@dvjsharma dvjsharma changed the title feat: Implemented Prisma ORM and Initial Database Setup feat: #117 feat: !(Breaking) Implemented Prisma ORM and Initial Database Setup feat: #117 Jul 22, 2024
@dvjsharma dvjsharma changed the title feat: !(Breaking) Implemented Prisma ORM and Initial Database Setup feat: #117 feat: !(Breaking) Implemented Prisma ORM and Initial Database Setup Jul 22, 2024
@dvjsharma dvjsharma merged commit 6e1f26b into dvjsharma:master Jul 22, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants