I am quite new to Replit and this level of ‘coding’. I have used the Agent to build a functional data-driven app (the uses the included Neon Postgres) and this is now deployed to live. I would now like to work on enhancements but want to be sure that when I deploy the next update, the production data is not overwritten.
How should I handle this? Or in fact, how does Replit handle it, especially when there are database schema updates due to the new features?
This is a deep-rooted challenge. Ideally, we should be able to separate the development and production environments with different databases. However, the current Replit specification doesn’t allow for this directly. I can suggest two potential solutions:
First Solution: I recommend using PostgreSQL schema separation. In the development environment, you can use the public schema (default schema), while in the production environment, you can create and use a new schema called “production” for data storage.
Second Solution: Although I haven’t tested this personally, you could consider contracting a separate Neon database. You would register the connection information for this separate Neon database during deployment. This approach would require creating database migrations for the new Neon database as well. However, it offers the advantage of complete database separation.
Thanks so much for the advice. My main concern was overwriting data in the deployed app. What I have now noticed is that when I am running the ‘dev environment’ in Replit and e.g. a new user signs up, their record is added to the production instance of Postgres, which made me realise that there is only a single DB instance. I will take a look at using two DB schemas some more. Thanks for the help!
I tried your approach but Agent have big issues to set properly… Maybe that should be considered at the beginning when I started building app. What are your experience with that? Thank you