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

Enhance npx prisma init: Pre-define basic model in schema.prisma for a smoother prisma studio experience #1284

Open
Milan-960 opened this issue Oct 30, 2024 · 0 comments
Labels
kind/bug A reported bug.

Comments

@Milan-960
Copy link

Milan-960 commented Oct 30, 2024

Bug description

Currently, when running npx prisma init, a user encounters an error message if they attempt to launch prisma studio without defining any models in their schema.prisma file. While the error message clearly guides the user towards defining a model, it can be a minor hurdle for beginners.

Suggestion:

To provide a more seamless experience for new users, consider incorporating a basic model pre-definition within the schema.prisma file generated by npx prisma init. This model could be something simple like:

model User {
  id     Int      @id @default(autoincrement())
  email  String   @unique
  name   String?
}

Benefits:

  • Reduced Friction for New Users: This pre-defined model would allow users to immediately explore prisma studio without encountering the initial error message, streamlining their onboarding journey.
  • Learning Opportunity: The basic model serves as a starting point for users to understand the concept of models and schema definition in Prisma. They can then customize or extend this model as their project evolves.

Additional Points:

  • Configuration Option: If providing a pre-defined model is deemed unnecessary, consider adding a configuration option within npx prisma init that allows users to choose whether or not to include a basic model.
  • Error Handling Improvement: Explore ways to enhance the error message when no models are defined. This could involve providing more specific guidance for defining a model alongside the link to the documentation.

How to reproduce

  1. Go to your project directory.
  2. Initialize a new Prisma project:
    npx prisma init
 3.Start Prisma Studio:
```bash
  npx prisma studio

Expected behavior

No response

Prisma information

schema.prisma

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init

generator client {
provider = "prisma-client-js"
}

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

Environment & setup

  • OS:
  • Browser:
  • Database:

Prisma logs

In what order to compile the files

Screenshot 2024-10-30

@Milan-960 Milan-960 added the kind/bug A reported bug. label Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A reported bug.
Projects
None yet
Development

No branches or pull requests

1 participant