prisma / nuxt-prisma

Prisma ORM integration for Nuxt
https://www.prisma.io/docs/orm/more/help-and-troubleshooting/help-articles/prisma-nuxt-module
62 stars 11 forks source link

schema.prisma not found after changing the location in NuxtJS #43

Open Aguix opened 6 days ago

Aguix commented 6 days ago

Bug description

In a NuxtJS project, when you change the location of the schema.prisma in the package.json and you do a npm run dev at the start of the process it says that the schema is not found in the custom location so it recreates it in the default location (screenshot 1). However at the end of the process it says that it successfully loaded the schema of the custom location (screenshot 2). image image

How to reproduce

In a NuxtJS project :

  1. Initialize Prisma in Nuxt projects with npm install @prisma/nuxt
  2. Add the module @prisma/nuxt to the modules in your nuxt.config.ts file
  3. Create the folder './server/prisma' and place your prisma schema inside
  4. In your package.json file add the following content
    "prisma" : {
    "schema" : "./server/prisma/schema.prisma"
    }
  5. Run npm run dev

Expected behavior

Use the schema.prisma at the custom location to create the database.

Prisma information

datasource db {
  provider = "sqlite"
  url      = env("DATABASE_URL")
}

model User {
  id       Int    @id @default(autoincrement())
  username String
  password String
}

model Option {
  id               Int              @id @default(autoincrement())
  name             String
  shortDescription String?
  longDescription  String?
  price            Float
  workTime         Int
  isAmountVariable Boolean
  optionGroup      OptionGroup      @relation(fields: [optionGroupId], references: [id])
  optionGroupId    Int
  bundles          OptionOnBundle[]
}

model OptionGroup {
  id          Int      @id @default(autoincrement())
  name        String
  description String?
  options     Option[]
}

model Bundle {
  id              Int              @id @default(autoincrement())
  name            String
  price           Float
  includedOptions OptionOnBundle[]
}

model OptionOnBundle {
  option   Option @relation(fields: [optionId], references: [id])
  optionId Int
  bundle   Bundle @relation(fields: [bundleId], references: [id])
  bundleId Int
  quantity Int

  @@id([optionId, bundleId])
}
// Add your code using Prisma Client

Environment & setup

Prisma Version

10.8.1
Aguix commented 21 hours ago

A found a way to fix the issue, how can I submit it ? I do a fork of the repo, add my change, test my fix and do a merge request ?