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

Integrate Prisma with Postgres in Backend #15

Closed
valon-loshaj opened this issue Oct 24, 2024 · 1 comment
Closed

Integrate Prisma with Postgres in Backend #15

valon-loshaj opened this issue Oct 24, 2024 · 1 comment
Assignees

Comments

@valon-loshaj
Copy link
Owner

valon-loshaj commented Oct 24, 2024

Set up Prisma as the ORM for database interaction and connect to a local Postgres instance.

Tasks:

  1. Install Prisma and the Postgres client:
    npm install prisma @prisma/client
    npm install pg
  2. Initialize Prisma in the backend/ folder:
    npx prisma init
  3. Update the .env file to include the Postgres connection string:
    DATABASE_URL="postgresql://user:password@localhost:5432/sidequest"
  4. Define the initial Prisma schema (prisma/schema.prisma) for users, quests, and characters.
    Example:
    model User {
      id        Int      @id @default(autoincrement())
      username  String   @unique
      password  String
      character Character
    }
    
    model Character {
      id         Int    @id @default(autoincrement())
      type       String
      level      Int
      experience Int
      userId     Int
      User       User    @relation(fields: [userId], references: [id])
    }
  5. Run npx prisma migrate dev to create the initial migration and sync the schema with the Postgres database.
  6. Verify Prisma is connected to the database by querying the users or characters table in the route /api/status.
@valon-loshaj valon-loshaj converted this from a draft issue Oct 24, 2024
@valon-loshaj
Copy link
Owner Author

Tasks:

  1. Set up PostgreSQL database
  2. Initialize Prisma in the project
  3. Create initial schema.prisma file
  4. Set up first migration
  5. Create basic seed data script
  6. Document database setup process

@valon-loshaj valon-loshaj self-assigned this Jan 2, 2025
@valon-loshaj valon-loshaj moved this from Todo to In Progress in side-quest Jan 7, 2025
@valon-loshaj valon-loshaj moved this from In Progress to Done in side-quest Jan 14, 2025
@valon-loshaj valon-loshaj closed this as completed by moving to Done in side-quest Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

1 participant