简体   繁体   English

用于开发生产环境的Postgres数据库设置

[英]postgres database setup for dev staging production enviroment

I'm deploying an App using PHP (CodeIgniter framework) and postgres (i'll probably use some javascript on the client side). 我正在使用PHP(CodeIgniter框架)和postgres(我可能会在客户端使用一些javascript)部署应用程序。

I'm using a Git repository with the dev-staging-production branches, and I'd like to know what is the best way to implement the databases with postgres. 我正在使用带有dev-staging-production分支的Git存储库,并且我想知道用postgres实现数据库的最佳方法是什么。

Should I create three tables for each with a prefix ie dev_, sta_, prod_? 我是否应该为每个表创建三个表,每个表都带有前缀dev_,sta_,prod_? should I synchronize some tables, and how should i sync them... 我应该同步一些表,以及如何同步它们...

Instead of multiple tables I'd either go with a) multiple schemas or b) multiple databases. 除了使用多个表之外,我还可以使用a)多个模式或b)多个数据库。 The latter option is preferrable since this allows you to run dev and staging databases on other hosts than the productions database. 后一种选择是可取的,因为它允许您在生产数据库之外的其他主机上运行开发和登台数据库。

In principle you would then manage your data in the production database only and sync them to the staging and dev database regularly or on demand, eg with pg_dump and pg_restore . 原则上,您将只在生产数据库中管理数据,并定期或按需将它们同步到登台和开发数据库,​​例如使用pg_dumppg_restore

halfer 's comment on managing schema changes is a good approach. Halfer在管理模式变更方面的评论是一种很好的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM