This document outlines the proper configuration for deploying the Marillac Place application to Railway.
Railway must have the following environment variables configured:
NODE_ENV=production
DATABASE_URL=<Railway-provided PostgreSQL URL>
FRONTEND_URL=https://mp-frontend-production.up.railway.app
JWT_SECRET=<secure secret>
ADMIN_STAFF_PASSWORD=<secure password>
RELIEF_STAFF_PASSWORD=<secure password>
SEED_TEST_DATA=true
Set SEED_TEST_DATA=true to seed test participant accounts in production for testing purposes.
- Test Participant IDs: 100, 101
- Test Password:
test123 - This creates minimal test accounts without the full mock data
Important Notes:
FRONTEND_URLshould include the protocol (https://) for proper CORS configuration- ✅ Correct:
https://mp-frontend-production.up.railway.app - ❌ Incorrect:
mp-frontend-production.up.railway.app - The backend code will auto-add
https://if missing, but it's best practice to include it
- ✅ Correct:
- Setting
NODE_ENV=productionis critical. This ensures: - Only system badges are seeded (no mock data)
- Database is not reset on deployment
- Production-appropriate behavior throughout the application
On first deployment to Railway, the database needs to be initialized with the schema and seeded with system badges:
- Railway will automatically run
prismaInitAndRunvia the Dockerfile - This will:
- Apply database schema via
prisma db push(production) orprisma migrate deploy(dev) - Generate Prisma client
- Sync Snaplet seed configuration
- Run the seed script (which checks
NODE_ENVto determine what to seed)
- Apply database schema via
The seed script (backend/seed/seed-snaplet.ts) is idempotent in production mode:
- It checks if badges already exist before seeding
- If badges exist, it skips seeding
- This prevents duplicate data on redeployment
- Seeds only system badges from
backend/seed/prodData.ts - Does NOT reset the database
- Does NOT seed mock data
- Only inserts badges if none exist (idempotent)
- Resets the entire database
- Seeds system badges
- Seeds mock data (participants, tasks, announcements, etc.)
If you need to manually seed the database on Railway:
yarn seed:prodSEED_TEST_DATA=true yarn seed:prodThis will seed:
- System badges (if not already present)
- 2 test participant accounts (IDs: 100, 101, password:
test123)
yarn seed:devCause: NODE_ENV is not set to production in Railway environment variables
Solution:
- Go to Railway project settings
- Add environment variable:
NODE_ENV=production - Redeploy the service
Cause: Production uses prisma db push instead of migrations
Solution:
- For production,
prisma db pushis used (as configured inprismaInitAndRun) - For complex schema changes, consider using migrations in production as well
- Modify the
prismaInitAndRunscript if needed
Cause: This is expected behavior, but the script is idempotent in production
Verification:
- Check logs for "Badges already exist, skipping seeding"
- This confirms the idempotent behavior is working correctly
-
Local Development (Docker): Uses
prismaInitAndRunwhich includes seeding- Runs via
yarn prismaInitAndRun(Dockerfile ENTRYPOINT) - Uses
NODE_ENV=development(or whatever is set in.env)
- Runs via
-
Railway Production: Uses
startscript- Railway's default is to run
yarn startfor Node.js apps startscript does NOT include seeding (correct for restarts)- Initial seeding happens via
prismaInitAndRunon first deployment
- Railway's default is to run
The Dockerfile is used by both:
- Docker Compose (local): Uses
ENTRYPOINT ["yarn", "prismaInitAndRun"] - Railway (production): Also uses the same Dockerfile
Railway respects the ENTRYPOINT, so both environments run prismaInitAndRun on container start.
- Never commit production credentials to
.envfiles - Set NODE_ENV=production in Railway environment variables
- Test seed scripts locally before deploying:
# Test production seeding locally NODE_ENV=production yarn seed:prod - Monitor Railway logs on deployment to verify seeding behavior
- Keep system badges in sync between
prodData.tsand production database