W
Wasp-langβ€’2mo ago
mnt

wasp db migrate-dev error with brand new installation

I started a brand new project to evaluate opensaas. I was able to start the postgres database in docker. When I try to run migrate-dev, I get the error described below. Can someone please give me a hand with this? 🐝 --- Setting up database... ----------------------------------------------------- [ Db !] Error: There is no datasource in the schema. [ Db !] [ Db !] [ Db ] Environment variables loaded from .env [ Db ] Prisma schema loaded from ../db/schema.prisma [ Db !] Error: [ Db !] You don't have any datasource defined in your schema.prisma. [ Db !] You can define a datasource like this: [ Db !] [ Db !] datasource db { [ Db !] provider = "postgresql" [ Db !] url = env("DB_URL") [ Db !] } [ Db !] [ Db !] More information in our documentation: [ Db !] https://pris.ly/d/prisma-schema [ Db !]
7 Replies
kapa.ai
kapa.aiβ€’2mo ago
Hi @mnt. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the error message you've provided, it seems that there's an issue with your Prisma schema file. The error indicates that there's no datasource defined in your schema.prisma file. This is unusual for a brand new Wasp project, especially if you're using the OpenSaaS template. Here are a few steps you can try to resolve this issue: 1. First, make sure you're in the correct directory of your Wasp project. 2. Check if the schema.prisma file exists in the main/db directory of your project. If it doesn't exist or is empty, there might be an issue with your project setup. 3. If the file exists, open it and check if it contains a datasource definition. It should look something like this:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

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

If this block is missing, you should add it to your schema.prisma file. 4. Make sure you have a .env file in your project root with the DATABASE_URL environment variable set correctly. It should look like this:
DATABASE_URL="postgresql://postgres:devpass@localhost:5432/postgres"

DATABASE_URL="postgresql://postgres:devpass@localhost:5432/postgres"

This assumes you're using the default setup for the PostgreSQL Docker container as described in the Wasp documentation (https://wasp-lang.dev/docs/data-model/backends#postgresql). 5. After making these changes, try running wasp db migrate-dev again. If you're still encountering issues after trying these steps, it might be worth checking if there are any problems with your Wasp installation. You could try running wasp clean and then wasp start again, as suggested in a similar Discord support thread (https://discord.com/channels/686873244791210014/1204021576979324949). If the problem persists, you might want to consider reinstalling Wasp or creating a new project from scratch. Make sure you're using the latest version of Wasp by running wasp version. Remember, when using Wasp with PostgreSQL, you need to ensure a database instance is running during development, and Wasp expects to find a connection string in the DATABASE_URL environment variable as described in the Wasp documentation (https://wasp-lang.dev/docs/data-model/backends#postgresql). If you continue to face issues, it might be helpful to share more details about your setup, including your Wasp version and the contents of your schema.prisma file (if it exists). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @mnt, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
mnt
mntOPβ€’2mo ago
OK, that's strange. there is a schema.prisma file in the root folder of the app already. I do have a .env file, but it says that the database url is not needed if you run wasp start db (which is what I did): NOTE: you can let Wasp set up your Postgres DB by running wasp start db in a separate terminal window. then, in a new terminal window, run wasp db migrate-dev and finally wasp start. If you use wasp start db then you DO NOT need to add a DATABASE_URL env variable here. I'm using wasp version 0.15.1 @kapa.ai
kapa.ai
kapa.aiβ€’2mo ago
Let me check the knowledge base for you again. One moment! :books: Sorry @mnt, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
mnt
mntOPβ€’2mo ago
@kapa.ai Does this error have anything to do with the wasp upgrade to 0.15.0
kapa.ai
kapa.aiβ€’2mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Based on the information provided in the knowledge sources, I don't have specific evidence linking this error to the Wasp upgrade to version 0.15.0. The error you're experiencing seems to be related to a missing datasource in the Prisma schema file, which is a fundamental configuration issue rather than a version-specific problem. However, it's worth noting that Wasp has had issues with Prisma versions in the past. For example: 1. There was an issue where Wasp failed to use the correct Prisma version when using Node.js 16.15.1, as mentioned in a GitHub issue (https://github.com/wasp-lang/wasp/issues/631). This was fixed by changing how Prisma was installed. 2. Another GitHub issue (https://github.com/wasp-lang/wasp/issues/158) mentions that Prisma introduced breaking changes in version 2.13, which broke Wasp at that time. These past issues suggest that Wasp upgrades can potentially affect Prisma-related functionality. However, without more specific information about changes in Wasp 0.15.0 related to Prisma or database configuration, I can't definitively say if your current error is related to this upgrade. To troubleshoot this issue: 1. Check if you're using the correct Wasp version by running wasp version. 2. Ensure your schema.prisma file is correctly configured as mentioned in my previous response. 3. If the problem persists, you might want to report this issue on the Wasp GitHub repository (https://github.com/wasp-lang/wasp/issues), providing details about your Wasp version, project setup, and the full error message. If you have any documentation or release notes specific to Wasp 0.15.0 that mention changes to database or Prisma configuration, that would be helpful to review in this context. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @mnt, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
mnt
mntOPβ€’2mo ago
For those who come here, the problem was with the version of node.js I was using. I had node 22 installed and when I downgraded to node 18, things just magically started working
miho
mihoβ€’2mo ago
Wasp 0.15.1 should work fine with Node.js 22, I've just created a new app:
# Create a new app
wasp new node22test -t saas
cd node22test/app
# Use Node.js 22
nvm use 22
# Start Postgres DB
wasp start db
# Run in a different terminal
wasp db migrate-dev
# Start the app
wasp start
# Create a new app
wasp new node22test -t saas
cd node22test/app
# Use Node.js 22
nvm use 22
# Start Postgres DB
wasp start db
# Run in a different terminal
wasp db migrate-dev
# Start the app
wasp start
This results in a working application πŸ€·β€β™‚οΈ Could you try these steps and see what happens?
Want results from more Discord servers?
Add your server