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

Error: P1003 Database dev.db does not exist #14

Open
elcreator opened this issue Dec 29, 2024 · 1 comment
Open

Error: P1003 Database dev.db does not exist #14

elcreator opened this issue Dec 29, 2024 · 1 comment

Comments

@elcreator
Copy link

Wasp should create the database before executing migration to prevent an error.

STR:

wasp new toodoo -t todo-ts
cd toodoo
wasp db migrate-dev
user@pc:/mnt/c/projects/wasptest/toodoo$ wasp db migrate-dev

🐝 --- Compiling wasp project... --------------------------------------------------


[  Wasp  ] Starting npm install
[  Wasp  ] Still installing npm dependencies!
[  Wasp  ] Installation going great - we'll get there soon!
[  Wasp  ] The installation is taking a while, but we'll get there!
[  Wasp  ] Yup, still not done installing.
[  Wasp  ] We're getting closer and closer, everything will be installed soon!
[  Wasp !] npm warn deprecated [email protected]: Use your platform's native atob() and btoa() methods instead
[  Wasp !] npm warn deprecated [email protected]: Use your platform's native DOMException instead
[  Wasp  ] Still waiting for the installation to finish? You should! We got too far to give up now!
[  Wasp  ] You've been waiting so patiently, just wait a little longer (for the installation to finish)...
[  Wasp  ] Still installing npm dependencies!
[  Wasp  ]
[  Wasp  ] added 451 packages, and audited 453 packages in 1m
[  Wasp  ]
[  Wasp  ] 107 packages are looking for funding
[  Wasp  ]   run `npm fund` for details
[  Wasp  ]
[  Wasp  ] 2 low severity vulnerabilities
[  Wasp  ]
[  Wasp  ] To address all issues (including breaking changes), run:
[  Wasp  ]   npm audit fix --force
[  Wasp  ]
[  Wasp  ] Run `npm audit` for details.
[ Client ] Starting npm install
[ Server ] Starting npm install
[ Server ] Still installing npm dependencies!
[ Client ] Still installing npm dependencies!
[ Server ]
[ Server ] added 140 packages, and audited 141 packages in 13s
[ Server ]
[ Server ] 24 packages are looking for funding
[ Server ]   run `npm fund` for details
[ Server ]
[ Server ] 3 high severity vulnerabilities
[ Server ]
[ Server ] To address all issues (including breaking changes), run:
[ Server ]   npm audit fix --force
[ Server ]
[ Server ] Run `npm audit` for details.
[ Client ] Installation going great - we'll get there soon!
[ Client ]
[ Client ] added 77 packages, and audited 78 packages in 20s
[ Client ]
[ Client ] 11 packages are looking for funding
[ Client ]   run `npm fund` for details
[ Client ]
[ Client ] found 0 vulnerabilities
✅ --- Successfully completed npm install. ----------------------------------------


🐝 --- Setting up database... -----------------------------------------------------


[   Db  !] Error: P1003
[   Db  !]
[   Db  !] Database `dev.db` does not exist at `/mnt/c/projects/wasptest/toodoo/.wasp/out/db/./dev.db`.
[   Db  !]
[   Db   ] Environment variables loaded from .env
[   Db   ] Prisma schema loaded from ../db/schema.prisma
[   Db   ]
[   Db   ] ✔ Generated Prisma Client (v5.19.1) to ./../../../node_modules/@prisma/client in 386ms
[   Db   ]
✅ --- Database successfully set up. ----------------------------------------------


🐝 --- Building SDK... ------------------------------------------------------------


✅ --- SDK built successfully. ----------------------------------------------------


✅ --- Your wasp project has successfully compiled. -------------------------------


🐝 --- Starting database migration... ---------------------------------------------

Environment variables loaded from .env
Prisma schema loaded from ../db/schema.prisma
Datasource "db": SQLite database "dev.db" at "file:./dev.db"

Applying migration `20240216105711_initial`

The following migration(s) have been applied:

migrations/
  └─ 20240216105711_initial/
    └─ migration.sql

Your database is now in sync with your schema.
@infomiho
Copy link
Collaborator

infomiho commented Jan 2, 2025

@elcreator thank you for your report!

This is a transitive error that happens when you use SQLite with a Wasp project and you are running the migrations for the first time. Wasp tries to execute something like

npx prisma migrate diff --from-schema-datamodel ./prisma/schema.prisma --to-schema-datasource ./prisma/schema.prisma --exit-code

to check if migrations are needed. This command produces the error your mentioned - but that's okay, Wasp now knows that migrations will be necessary. As soon as Wasp runs initial migration command, the dev.db file is created and this error now resolved.

In other words, this is not an error when looking from Wasp's point of view but an information about the state of the migrations. We should potentially add an extra check if the dev.db exists and not execute the diff check so users don't see this transitive error. I'll leave this issue open for now until we agree on what do we want to do internally :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants