Drupal 部署/测试/不知道如何调用它工具
设置如下: Drupal 项目,一个带有主干/qa/生产就绪分支的 svn 存储库,每个分支的虚拟主机,将文件从存储库复制到文档根的提交后挂钩。
问题如下:Drupal 网站通常不仅依赖于源代码,还依赖于数据库数据(节点类型、它们的设置等)。
我正在寻找解决方案以使此更改可版本化。 但不像“比较”数据库中的所有数据,而是类似于单元测试中的固定装置。
类似夹具的脚本,包含 SQL 数据和内容文件,这些内容应该是可版本控制的,并在主提交后挂钩之后应用。
是否有为此目的编写的任何内容,或者可能很容易采用某种构建工具(如 Apache Ant)或单元测试框架。 如果这个工具了解 drupal,那就太好了,这样我就可以在脚本中执行 variable_set()
、drupal_execute()
等操作。
有任何想法吗? 或者我应该立即开始编码而不是问这个? :)
Setup is following:
Drupal project, one svn repo with trunk/qa/production-ready branches, vhosts for every branch, post-commit hook that copies files from repository to docroots.
Problem is following: Drupal website often relies not only on source code but on DB data too (node types, their settings, etc.).
I'm looking for solution to make this changes versionable. But not like 'diffing' all data in database, instead something like fixtures in unit tests.
Fixture-like scripts with SQL data and files for content that should be versionable and be applied after main post-commit hook.
Is there anything written for that purpose, or maybe it would be easy to adapt some kind of build tool (like Apache Ant) or unit testing framework. And it would be very great, if this tool know about drupal, so in scripts I can do things like variable_set()
, drupal_execute()
.
Any ideas? Or should I start coding right now instead of asking this? :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
听起来您已经在那里编写了一些基础设施。
所以我开始编码! 目前据我所知,没有任何事情对此特别有利。 如果有的话,我想需要付出一些努力才能使其与您现有的基础设施一起运行。 所以开始编码似乎是一条出路。
我的方法是使用 sql 补丁文件(包含用于升级数据库模式/数据的 sql 语句的文件),并在文件名开头添加版本号。 然后,数据库包含一个包含配置信息的表(您可能已经有这个),其中包含有关数据库所在版本的信息。
然后,您可以采取多种方法来自动应用补丁。 一种是您从提交后调用的脚本,该脚本检查数据库所在的版本,然后检查您拥有补丁的最新版本是否比数据库所在的版本更新,然后应用它/它们(按顺序)如果是这样。
数据库补丁应始终通过更新配置表中的上述版本号来完成。
这种方法可以扩展到包括基于完整转储文件设置新数据库,然后对其应用任何必要的补丁以对其进行升级的能力。
It sounds like you've already got some infrastructure there that you've written.
So I'd start coding! There's not anything that I'm aware of thats especially good for this at the moment. And if there is, I imagine that it would take some effort to get it going with your existing infrastructure. So starting coding seems the way to go.
My approach to this is to use sql patch files (files containing the sql statements to upgrade the db schema/data) with a version number at the start of the filename. The database then contains a table with config info in (you may already have this) that includes info on which version the database is at.
You can then take a number of approaches to automatically apply the patch. One would be a script that you call from the postcommit that checks the version the database is at, and then checks to see if the latest version you have a patch for is newer than the version the db is at, and applies it/them (in order) if so.
The db patch should always finish by updating aforementioned the version number in the config table.
This approach can be extended to include the ability to set up a new database based on a full dump file and then applying any necessary patches to it to upgrade it as well.
在最近的一次会议上对此进行了演示(slideshare 链接)——我强烈建议您使用特定于站点的自定义模块,其 .install 文件包含版本化“更新”功能,这些功能可以完成数据库架构更改和设置/配置更改的繁重工作。
它绝对优于保留 .sql 文件,因为 Drupal 将跟踪哪些文件已运行,并为您提供批处理机制,用于任何需要对大量数据进行长时间运行的批量操作的情况。
Did a presentation on this at a recent conference (slideshare link) -- I would STRONGLY suggest that you use a site-specific custom module whose .install file contains versioned 'update' functions that do the heavy lifting for database schema changes and settings/configuration changes.
It's definitely superior to keeping .sql files around, because Drupal will keep track of which ones have run and gives you a batch-processing mechanism for anything thaht requires long-running bulk operations on lots of data.
我正在考虑具有所需数据库结构的文件(xml 或其他内容)以及应用必要更改的工具。
是的,经过更多研究,我同意:对其进行编码比采用其他一些解决方案更容易。 虽然我认为 simpletest drupal 模块中的一些例程会有所帮助。
I was thinking of file (xml or something) with needed DB structure, and tool that applies necessary changes.
And yes, after more research I agreee: it will be easier to code it than to adapt some other solutions. Though some routines from simpletest drupal module will be helpful, I think.
您可能想看看重构数据库这本书。
我从一位作者那里听到的建议是使用一个脚本将数据库从一个版本升级到另一个版本,而不是每次都从头开始构建。
You might want to check out the book Refactoring Databases.
The advice I heard from one of the authors is to have a script that will upgrade the database from version to version rather than building up from scratch each time.
以前:Drupal 源代码控制策略?
Previously: Drupal Source Control Strategy?