Database in Production Server

Hello! I am new to coding and GitHub and have database questions. When I push code to GitHub and then deploy it on a host elsewhere on the Internet, how exactly does my database data get saved throughout the process? If users add to my database via posts or registrations when the server is in production, how/where does that get saved? If I were to push a new version of my program to GitHub and then deploy that, would all the data to that point be lost?

Any info would be appreciated! Thank you!

That’s up to you and the deployment process you create, and has nothing to do with Github. :slightly_smiling_face:

One common approach would be to manage the database server and the application that use it separately, so you just replace the application while the database stays as it is. If an application update changes the database structure you’ll need an additional database update step, unless your application can just update the schema and adjust the data as needed.

Another related consideration is backup. You probably want your production data safe even if your database server crashes horribly, hard drives blow up, and so on. For that you need a backup, and you should also test the restore process to make sure it works right. You could also use a backup to restore user data after a complete wipe and reinstall of the database, if you plan on doing that make sure to stop anything that might update user data and create a fresh backup first.