Development and Production Should Not Share the Same Database
For a small project, using the same backend while developing and running the live application is incredibly convenient.
It is also something I now try to avoid.
The problem becomes obvious as soon as development involves anything destructive. Maybe I want to reset some data, test a migration, create hundreds of fake records or run a script that recalculates something for every user.
If my development environment is connected to production, one mistake can become a real incident.
The safer setup is conceptually simple:
development app → development backend/database
production app → production backend/database
Each environment gets its own credentials and configuration. Ideally, switching between them is controlled through environment variables rather than manually editing URLs in the code.
This also makes testing more realistic. I can create strange data, delete everything, rerun migrations and break things without worrying about actual users.
The separation becomes especially useful for backend scripts. An administrative script that can update thousands of records should make it extremely obvious which environment it is about to touch.
I am starting to prefer safeguards that make mistakes difficult rather than relying on myself to remember not to make them.
Separate databases are a little more setup at the beginning, but compared with accidentally running a development command against production, that setup is extremely cheap.
Topics
