After deploying on Railway, database schema changes are not propagated

Wondering why my app isn't working, I check in the server logs to find there area lot of errors related to an undefined database field. This is because we added a database field after deploying to Railway. Now we have steps for deploying the client, and deploying the server that both involve using the Railway CLI ("railway up"), however this step does not seem to address migrations. I've tried changing the DATABASE_URL in my local .env.server to the URL provided by Railway and running "wasp db migrate-dev". This fails with: ❌ --- [Error] Can not connect to database: --------------------------------------- The database needs to be running in order to execute this command. You can easily start a managed dev database with wasp start db. How to deploy migrations to Railway?
4 Replies
MEE6
MEE63mo ago
Wohooo @Conspyre, you just became a Waspeteer level 6!
kapa.ai
kapa.ai3mo ago
Hi @Conspyre. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To deploy migrations to Railway, you need to run the wasp db migrate-dev command with the DATABASE_URL set to the URL provided by Railway. However, as you've noticed, this command requires the database to be running. The error message you're seeing suggests that the database server at the specified DATABASE_URL is not accessible. This could be due to a number of reasons, such as incorrect database credentials, network issues, or the database server not running. Here are some steps you can take to troubleshoot this issue: 1. Double-check the DATABASE_URL provided by Railway. Make sure it's correctly set in your .env.server file. 2. Ensure that your local machine has network access to the Railway database. This might involve configuring firewall rules or other network settings. 3. Make sure the Railway database server is running. You can check this from your Railway dashboard (https://railway.app/dashboard). If you're still having trouble, you might find it helpful to consult the Wasp documentation (https://wasp-lang.dev/docs/advanced/deployment/manually#deploying-the-server) or ask for help on the Wasp GitHub page (https://github.com/wasp-lang/wasp/issues). Please note that the wasp db migrate-dev command is designed to be used in a development environment. For deploying migrations in a production environment, you might need to use a different command or process. Please consult the Wasp and Prisma documentation for more information on this. Sources: - Wasp Deployment Documentation (https://wasp-lang.dev/docs/advanced/deployment/manually#deploying-the-server) - Wasp GitHub Issue #1486 (https://github.com/wasp-lang/wasp/issues/1486) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Conspyre, 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?
Conspyre
ConspyreOP3mo ago
UPDATE: found this. In Railway, select the "Postgres" block -> Data tab -> "Connect to the database" -> Public Network -> Connection URL. Copy that and put it in your DATABASE_URL in your local .env.server. Now do a "wasp db migrate-dev" and your migration will be applied to Railway db.
miho
miho2mo ago
Did you deploy to Railway according to our instructions? https://wasp-lang.dev/docs/advanced/deployment/manually#railway-server-client-and-database If yes, then there is no need to manually trigger the migrations since our default Docker setup runs prisma migrate deploy on each deployment 🙂 I'm not sure what kind of custom setup you have that you need to manually trigger the migrations
Deploying Manually | Wasp
This document explains how to build and prepare your Wasp app for deployment.
Want results from more Discord servers?
Add your server