Skip to content

Latest commit

 

History

History
92 lines (70 loc) · 3.06 KB

File metadata and controls

92 lines (70 loc) · 3.06 KB

NEET.me - Railway Deployment Summary

✅ Changes Made for Railway Deployment

1. Database Migration

  • ✅ Updated Prisma schema to use PostgreSQL (required for all environments)
  • ✅ Changed avatar field to @db.Text for storing base64 data
  • ✅ Changed icon field in Link model to @db.Text for base64 storage
  • PostgreSQL is now required for both development and production

2. Image Storage

  • Avatar Upload API (/api/upload/avatar.ts): Now stores base64 data directly in database
  • Image Serving API (/api/images/avatar/[userId].ts): Serves images from database as binary data
  • ✅ All user-uploaded content (avatars, custom link icons) now stored in PostgreSQL

3. Configuration Files

  • ✅ Created .env.example with all required environment variables
  • ✅ Created railway.json for Railway-specific configuration
  • ✅ Updated package.json with Railway build scripts
  • ✅ Updated .gitignore to exclude SQLite database files

4. Documentation

  • ✅ Created RAILWAY_DEPLOYMENT.md with complete deployment guide

📋 Pre-Deployment Checklist

Before deploying to Railway:

  1. GitHub Setup

    • Initialize git repository
    • Push code to GitHub
    • Verify all files are committed
  2. Railway Setup

    • Create Railway account
    • Create new project from GitHub repo
    • Add PostgreSQL database service
    • Configure environment variables (see .env.example)
  3. Reown Configuration

    • Get Reown Project ID from dashboard.reown.com
    • Update Reown dashboard with Railway domain
    • Add Railway domain to allowed origins
  4. Environment Variables (Set in Railway)

    DATABASE_URL (auto-set by Railway)
    NEXT_PUBLIC_REOWN_PROJECT_ID
    NEXT_PUBLIC_APP_URL
    NEXTAUTH_URL
    NEXTAUTH_SECRET
    NODE_ENV=production
    
  5. Database Migration

    • Run npx prisma db push after first deployment
    • Or use Railway CLI: railway run npm run railway

🚀 Deployment Steps

  1. Push code to GitHub
  2. Railway auto-detects Next.js and starts building
  3. Add PostgreSQL database in Railway
  4. Set environment variables
  5. Run database migration: railway run npm run railway
  6. Deploy and test!

📝 Important Notes

  • PostgreSQL is required for all environments (development and production)
  • Images are stored in database as base64 data URIs
  • No filesystem storage - everything is in PostgreSQL
  • Database migrations must be run manually after first deployment
  • Environment variables must be set before deployment

Local Development Setup

For local development, you need a PostgreSQL database:

  • Install PostgreSQL locally, OR
  • Use Docker: docker run --name postgres -e POSTGRES_PASSWORD=password -p 5432:5432 -d postgres, OR
  • Use a cloud PostgreSQL service (Railway, Supabase, Neon)

🔧 Troubleshooting

If deployment fails:

  1. Check Railway build logs
  2. Verify all environment variables are set
  3. Ensure PostgreSQL is connected
  4. Run prisma db push manually if needed

See RAILWAY_DEPLOYMENT.md for detailed instructions.