How do you manage databases in development, test, and production?

前端 未结 14 2073
情书的邮戳
情书的邮戳 2020-11-30 16:23

I\'ve had a hard time trying to find good examples of how to manage database schemas and data between development, test, and production servers.

Here\'s our setup. E

14条回答
  •  旧时难觅i
    2020-11-30 16:47

    • Name your databases as follows - dev_<> , tst_<> , stg_<> , prd_<> (Obviously you never should hardcode db names
    • Thus you would be able to deploy even the different type of db's on same physical server ( I do not recommend that , but you may have to ... if resources are tight )
    • Ensure you would be able to move data between those automatically
    • Separate the db creation scripts from the population = It should be always possible to recreate the db from scratch and populate it ( from the old db version or external data source
    • do not use hardcode connection strings in the code ( even not in the config files ) - use in the config files connection string templates , which you do populate dynamically , each reconfiguration of the application_layer which does need recompile is BAD
    • do use database versioning and db objects versioning - if you can afford it use ready products , if not develop something on your own
    • track each DDL change and save it into some history table ( example here )
    • DAILY backups ! Test how fast you would be able to restore something lost from a backup (use automathic restore scripts
    • even your DEV database and the PROD have exactly the same creation script you will have problems with the data, so allow developers to create the exact copy of prod and play with it ( I know I will receive minuses for this one , but change in the mindset and the business process will cost you much less when shit hits the fan - so force the coders to subscript legally whatever it makes , but ensure this one

提交回复
热议问题