Skip to content

Commit

Permalink
Add section on local and prod db differences
Browse files Browse the repository at this point in the history
  • Loading branch information
guudewie authored and 01zulfi committed Jan 14, 2025
1 parent d0815a8 commit 2c2586b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions nodeJS/express/using_postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@ You can then run this script via `node db/populatedb.js`, or add it as a [script

Do note that the script is designed to be ran only once.

#### Local vs production dbs

Great! You've just learned how to set up and use a local db with PostgreSQL. Local databases are ideal for development because they offer faster interactions, easier modifications, and don't require an internet connection. This makes them especially useful when prototyping or testing new features.

When you're ready to make your project public, you'll need to transition to a production database hosted on an external server independent of your local machine. A production database allows for global accessibility, scalability and more robust security. Most of the hosting providers introduced in the [deployment lesson](https://www.theodinproject.com/lessons/node-path-nodejs-deployment) also offer database services. Now that we know the difference, lets see how we can populate a production database.

#### Populating production dbs

We've hardcoded our local db connection information in the script. Hence, the script only populates our local db. We need a way to populate our production db as well. One way to do this is by using environment variables, though this leads to unnecessary hassle. Why? Because now, the script can only populate the production db on the production server i.e. we'll need to access the production server's cli to run the script. Or, we could sneakily edit our environment file to point to the production db and run the script on our machine, and revert it.
Expand Down

0 comments on commit 2c2586b

Please sign in to comment.