Manage DEV STAGING AND PROD

Hi guys do you have a clean method to manage env for your apps/databases ? it’s a basic thing but seems that it’s not descrbibe anywhere

2 Likes

Before suggesting solutions, I’d like to clarify a couple things about your environment management needs:

  • First, are you looking to separate configuration between development and staging environments?
  • When you mention “manage env”, are you specifically talking about managing environment variables like API credentials and connection strings?

As a starting point, I’d recommend looking into Replit’s Secrets feature, which provides a secure way to manage sensitive information: Secrets | Replit Docs

This should give you a good foundation to build upon. Let me know if I’ve understood your needs correctly, and I can provide more specific guidance.

Separate environment for dev. Test and prod, separate databases, separate endpoints,…

yea would be great to have something for this, at least a way to keep working on it in replit while the production ready thing is running with real data in database, and a test database for developing new functions and features.

This is indeed a fundamental challenge. Let me suggest a couple of approaches for separating your development and production environments, since Replit doesn’t provide direct support for this:
Option 1: PostgreSQL Schema Separation
You can leverage PostgreSQL’s schema functionality. Use the default ‘public’ schema for development, and create a separate ‘production’ schema for your production data. This keeps environments separate while using the same database instance. However, be extremely cautious with database rollbacks - since both schemas are in the same database, any global operations could potentially affect your production data. You’ll need to be very careful with migration management.
Option 2: External Database Integration
While I haven’t personally implemented this, you could connect to a separate Neon database instance. You’d configure the connection string during deployment. This would require setting up database migrations for the new Neon instance, but it gives you complete separation between environments.
Both approaches have their merits, depending on your specific needs and constraints.

1 Like

i already use the schema but to be honest it’s not safe at all imagine launching a migration on prod without testing it you can destroy your db :confused: would be nice to have this env split automatically handled in the repl

I had this issue. Agent/Assistant will tell you that you can have segregated databases within one Repl but they LIE!!! lol. I chatted with support after having issues. They said you have to create a blank Repl (to segregate DBs), then you can use Git/GitHub to clone your Development Repl into the blank Repl to create the Production Repl with cleanly segregated databases. Once that’s done you can easily push/pull your updates from your development Repl into your production Repl.

One suggestion that I saw but haven’t tried from @robinbobinpopin is to create new branches for each new feature you add. I think it’s so that you can roll back to any previous working state if I understand correctly. I dunno, people seem to like that suggestion.

Hope this helps!

1 Like

thanks this is exactly what i am doing - thaught we would have an easier way!

The Replit team is currently hosting a beta for about another week, so hop in, try it out, and share your thoughts to help make it even better: Best Practice for Managing Dev and Production Environments in a Live Game - #11 by kody-replit