Running database migrations on hosted app
Hey everyone! I have my app hosted on Fly.
- When I try to sign up or log in, it says "Save failed: there was a database error" (see image 1).
- The Fly monitoring logs state the issue quite clearly: "π This error can happen if you did't run the database migrations" (see image 2).
How do I go about running database migrations before I deploy a new release? I was looking at the Fly docs https://fly.io/docs/reference/configuration/#the-deploy-section, which say to add a
release_command
to the .toml file.14 Replies
In a deployed app, we run the migrations on every application start. If there are any new migrations, they get applied, if not, nothing happens π so I don't think you need to do anything for migrations AFAIK
The error message that says "π This error can happen if you did't run the database migrations" might be right but maybe we have some other issue as well.
- Could maybe scroll a bit up in the backend logs to see the full error? π
- Does your app work locally okay? π
Hi @miho thanks so much for responding. I attached a video showing the console errors and Fly logs as I load the website and attempt signup. The app works locally just fine! π
Wohooo @manaphy, you just became a Waspeteer level 1!
I see that it says "public.User" doesn't exist in the current database π€¨
I think we need to connect to the production database and see what's inside!
1οΈβ£ You can use the Fly CLI for that:
It will connect you to the PSQL tool that Postgres uses to give commands to the DB.
2οΈβ£ Write:
3οΈβ£ You'll se a list of available databases. Connect to your DB by running:
4οΈβ£ Execute the following to see the list of DB tables:
For the usual scenario, we expect to see something like this:
@manaphy which Wasp version is this, 0.11 or 0.12? Also, did you do any changes between when the app was still working and when it stopped working?
Hi @miho and @martinsos, thank you for your responses!
- After
\l
, I'm able to view the list of databases (see image), but I can't connect to any of them. Any key I hit causes the Windows error sound. π
- This is Wasp v0.12.4. After my hosting issue (https://discord.com/channels/686873244791210014/1216905991958827018), I updated to 0.12.4 and was successfully able to deploy. But that's all I've been able to do (deploy and view the landing page). I haven't been able to log in or sign up at all.Discord
Discord - A New Way to Chat with Friends & Communities
Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
@manaphy after you see the list of the DBs press q to exit that view and then you'll be able to continue π
Interesting, this is all I see.
prisma_migrations
is there but none of the other stuff!Could you do SELECT * FROM _prisma_migrations;
Obv something went wrong when applying migrations. Maybe deleting the apps on Fly and redeploying would be the best
Nothing happens when I enter
SELECT * FROM _prisma_migrations
in the CLI π¦
I also tried deleting the apps and redeploying, but the same issue is occurring π¦Could you DM me with your repository π€¨ I'll try to debug it on my computer π
Yes, I just sent you the link! Thanks so much
One thing I noticed in your repository is that you don't have any migrations. This leads me to believe you never ran the
wasp db migrate-dev
π This is something listed here: https://docs.opensaas.sh/start/getting-started/
It's important to run that command to get the latest Prisma models ready for your DB (which will be added to your local DB when you run the command and on deploy to your production DB). This will enable you to login and have a functioning app in general π
Read more about entities in the Wasp docs: https://wasp-lang.dev/docs/data-model/entities
I'd suggest even going through the Wasp tutorial quickly: https://wasp-lang.dev/docs/tutorial/createThanks @miho! I ran a database migration and redeployed. Login/signup work perfectly now! I appreciate your patience and willingness to help. :wasplang: βΊοΈ
@Wasp Team I learned a lot playing around with Wasp and had a lot of fun. Thank you for building and releasing it for free. :boi: