Overview
Emergent has three types of deployments, each handling your code and data differently. Understanding these is crucial to avoid data loss.First Deploy
Brand new appFresh database
Redeploy
Update existing appData preserved
Replace Deployment
Swap appsOptional data transfer
1. First Deploy (New App)
When It Happens
You click “Deploy” for the very first time on a project that has never been deployed.What Gets Created
Data State
Everything is NEW:- Fresh database (empty apart from preview data)
- New secrets from
.env - New URL
Perfect for: Launching a brand new app for the first time.
2. Redeploy (Update Existing)
When It Happens
You click “Deploy” on an app that’s already live.What Gets Updated
Code Changes:- Latest code from development pod -not data (images, files, data do not show up)
- Updated application
- Database (with ALL data preserved!)
- Existing secrets (not overwritten!)
- Same URL
- Same app identity
How Data is Handled
MongoDB Data
100% PRESERVED
- Same database connection
- All existing data intact
- No data loss
- Users unchanged
- Records preserved
Secrets
PRESERVED + MERGED
- Existing secrets preserved
- Not overwritten
- Only new keys added
- Old values kept
Important Secret Behavior
Existing secrets are NEVER overwritten! Example: [to be revisited].env
3. Replace Existing Deployment
When It Happens
You fork a project and choose to replace an existing deployed app when deploying the fork. **Use Cases: **Replacing app 1 with app 2 or app 1 with app 1.2 _Why does a user need to replace deployment? _- auto forking
- manual forked therefore new job ID and separate application on backend.
- or a completely new app that you want deployed instead of a discarded app.
What It Does
This deploys a completely NEW app and removes the previously deployed app. Flow:- Build new app from forked code or a completely new app
- (Optional) Transfer data from old app (Refer to the two options for data handling)
- Switch traffic to new app and the old app is deleted.
- New app is live for users.
- The new app uses the deployment fees from the next cycle onwards.
Two Options for Data Handling
Without Data Persistence
Fresh Start
- New empty database
- Old data NOT transferred
- Preview data from the new app is copied to the new deployment
- New app’s secret values are added to the existing app’s .env file - old keys are not auto-updated.
With Data Persistence
Keep Your Data
- Database connection copied
- All data preserved
- Same database used
- New app’s secret values are added to the existing app’s .env file - old keys are not auto-updated.
What Gets Created (New App)
Always NEW:- New app identity
- New deployment
- Database: New (no persist) or Same (with persist)
- Secrets: Copied from old app + appended with new
.env
- Old app identity
- Old deployment
- Old service and resources
- Old app record
When to Replace
Replace deployment when:- Forked to fix issues, want to swap
- Want to upgrade with major changes
- Just updating code in the same job→ Use Redeploy instead!
- Want to keep both versions → Deploy as separate app
Data Survival Guide
Here’s what survives in each scenario:| What | First Deploy | Redeploy | Replace (Fresh Database) | Replace (Keeping Old Database) |
|---|---|---|---|---|
| Source Code | New | Updated | New from fork | New from fork |
| MongoDB Data | Empty | PRESERVED | Lost | PRESERVED |
| Database URL | New | Same | New | Copied from old |
| Secrets | From .env | PRESERVED | Copied from old | Copied from old |
| App URL | New | Same | New/Transferred | New/Transferred |
| Container Image | New | New version | New | New |
Preview vs Production
Development Pod (Preview)
What it is:- Your testing environment
- Where you build and preview
- Temporary workspace
- Separate test database
- NOT connected to production
- Data here is NOT production data
- Can be deleted anytime
- Writing code
- Testing features
- Seeing changes
- Only you (developer)
Production Deployment (Live)
What it is:- Your live, public app
- What customers use
- Real production environment
- Production MongoDB - Managed via Cloud
- Real user data
- Persistent across redeploys
- Connected to always live URL
- Serving real users
- Storing real data
- Running your business
- Your customers
Key Point: Preview and Production use completely different databases. They never share data!
How Secrets Work
First Deploy
Redeploy
Replace Deployment
Common Scenarios
Scenario 1: Fixing a Bug
Scenario 2: Adding Major Features after Forking
Scenario 3: Starting Completely Fresh
Scenario 4: First Time Going Live
Decision Tree
Should I Deploy, Redeploy, or Replace?Best Practices
Do This
For Regular Updates:Avoid This
Don’t:- Forget to check “preserve data” if you need it
- Expect .env changes to update existing secrets
- Delete production app without backing up data
Data Safety Checklist
Before deploying:- Know which deployment method you’re using
- Understand if data will be preserved
- If replacing, decided on whether to keep data or not
- Backed up important data (if starting fresh)
- Tested thoroughly in preview
- Checked secrets are correct
- Ready for production traffic
Common Questions
Will redeploy delete my database?
Will redeploy delete my database?
No! Redeploy NEVER deletes your data.Your database and all data are 100% preserved on redeploy.Only code changes are deployed.
How do I update a secret in production?
How do I update a secret in production?
You can’t update existing secrets via .env on redeploy.To update an existing secret:
- Access deployment settings
- Find secret management section
- Update the secret value directly
What happens to old data when I replace deployment?
What happens to old data when I replace deployment?
Depends on your choice:With “Preserve data” checked:
- Data is transferred to new app
- All data accessible
- Old database becomes orphaned
- New app gets empty database
- Old data still exists but inaccessible
Can I deploy a fork as a separate app?
Can I deploy a fork as a separate app?
Yes! Just deploy without choosing “Replace existing.”This creates a completely separate app with:
- New URL
- New database
- Independent from original
Is preview data the same as production data?
Is preview data the same as production data?
No! They use completely different databases.Preview: Test database (local to development pod) Production: Real database (MongoDB Atlas)Changes in preview don’t affect production data.
How do I backup my production data?
How do I backup my production data?
Currently, backups are handled by the platform’s MongoDB hosting.For manual backup:
- Export data via your app’s admin interface
- Use database export tools
- Contact support for database snapshot
Quick Reference
First Deploy
- When: First time deploying
- Creates: Everything new
- Data: Empty database
- Use for: Initial launch
Redeploy
- When: Updating live app
- Updates: Code only
- Data: ✅ Preserved
- Use for: Regular updates
Replace (with persist)
- When: Swapping apps, keep data
- Creates: New app
- Data: ✅ Transferred
- Use for: Major refactor with data
Replace (without persist)
- When: Fresh start
- Creates: New app
- Data: ❌ Not transferred
- Use for: Complete reset
Remember
✅ Redeploy is safe - Data always preserved ✅ Preview ≠ Production - Different databases ✅ Secrets persist - Existing ones not overwritten ✅ Choose carefully - Replacement with/without data ✅ Test in preview first - Before production deploy ❌ Can’t update secrets via .env - Use platform settingsNeed Help?
Unsure Which to Use?
Lost Data After Deployment?
Secret Not Updating?
Best practice: For 99% of updates, just use Redeploy. It’s safe, preserves all data, and updates your code. Only use Replace when you have a specific reason!