Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Development and Production Database?

Tags:

mysql

I'm working with PHP & mySQL. I've finally got my head around source control and am quite happy with the whole development (testing) v production v repository thing for the PHP part.

My new quandary is what to do with the database. Do I create one for the test environment and one for the production environment? I currently have just the one which both environments use, leaving my test data sitting there. I kind of feel that I should have two, but I'm nervous in terms of making sure that my production database looks and feels exactly the same as my test one.

Any thoughts on which way to go? And, if you think the latter, what the best way is to keep the two databases the same (apart from the data, of course...)?

like image 425
Humpton Avatar asked Nov 18 '08 20:11

Humpton


People also ask

What is software development database?

A database typically requires a comprehensive database software program known as a database management system (DBMS). A DBMS serves as an interface between the database and its end users or programs, allowing users to retrieve, update, and manage how the information is organized and optimized.

What is a production database?

A production database contains the data you are using for production tasks such as creating and updating features. Depending on the data model you are using, data in a production database can be used to create a digital or hard-copy map or chart or a specific type of data.


3 Answers

Each environment should have a separate database. Script all of the database objects (tables, views, procedures, etc) and store the scripts in source control. The scripts are applied first to the development database, then promoted to test (QA, UAT, etc), then production. By applying the same scripts to each database, they should all be the same in the end.

If you have data that needs to be loaded (code tables, lookup values, etc), script that data load as part of the database creation process.

By scripting everything and keeping it in source control, a database structure can be recreated at any time for any given build level.

like image 152
ahockley Avatar answered Oct 07 '22 19:10

ahockley


You should definitely have two. As far as keeping them in sync, you should always create DDL for creating your database objects. Treat these scripts as you do you PHP code - keep them in version control. Anytime you have to modify the test database, make a script to do so, and check it in. Then you can propogate those changes to the production system once you are ready.

like image 26
Brett McCann Avatar answered Oct 07 '22 19:10

Brett McCann


As a minimum one database for each development workstation and one for production. Besides that you should have one for the test environment unless you are only one developer and have a similar setup as the production environment.

like image 2
Jonas Kongslund Avatar answered Oct 07 '22 18:10

Jonas Kongslund