好的DB迁移为CakePHP? [英] Good DB Migrations for CakePHP?

查看:155
本文介绍了好的DB迁移为CakePHP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试CakePHP的几个迁移脚本,但是我遇到了一些形式或其他形式的问题。

I have been trying a few migration scripts for CakePHP but I ran into problems with all of the in some form or another.

请在迁移选项

我想要以下功能:


  • 支持CakePHP 1.2(例如,当1.3稳定且我的应用程序迁移到新代码库时,CakeDCs迁移将是一个选项)

  • 支持

  • 在插件的支持模型

  • 支持不符合Cake惯例的表(我有几个特殊的表,没有一个主键字段,需要保留它们)


  • Support CakePHP 1.2 (e.g. CakeDCs migrations will only be an option when 1.3 is stable and my app migrated to the new codebase)
  • Support for (or at least not halt on) Models with a different database config.
  • Support Models in sub-folders of app/models
  • Support Models in plugins
  • Support tables that do not conform to Cake conventions (I have a few special tables that do not have a single primary key field and need to keep them)
  • Plays well with automated deployment via Capistrano and Git.

我不需要rails样式的版本化文件git版本的模式文件到现有的模式会做。也就是:我喜欢Cake中的SchemaShell,除了它不符合我上面的大多数需求。

I do not need rails-style versioned files a git versioned schema file that is compared live to the existing schema will do. That is: I like the SchemaShell in Cake apart from it not being compatible with most of my requirements above.

我已经看过并测试了:

  • CakePHP Schema Shell http://book.cakephp.org/view/734/Schema-management-and-migrations
  • CakeDC migrations http://cakedc.com/downloads/view/cakephp_migrations_plugin
  • YAML migrations http://github.com/georgious/cakephp-yaml-migrations-and-fixtures
  • joelmoss migrations http://code.google.com/p/cakephp-migrations

推荐答案

我会尝试更新此主题我的发现迅速尝试胡安的插件和所有其他人提到除了那个从CakeDC ...因为我没有相关的应用程序更新为CakePHP 1.3和迁移插件需要1.3

I'll try to update this "topic" with my findings after quickly trying Juan's plugin and all the others mentioned except the one from CakeDC... since I don't have the relevant app updated for CakePHP 1.3 and that migration plugin requires 1.3

我必须注意,对于不适合我的失败和插件的评论应该主要读为不适合我的需要或我在尝试它们时犯的错误。在某种程度上,有些人可能会读这样的意见,要求修改文件。我不暗示测试的插件本身有缺陷,错误或破损。

I must note that comments about failures and plugins not working for me should be read primarily as "not suitable for MY needs" or "mistakes I have made while trying them". To some extent some might read such comments as a plea for a revision in documentation. I do not imply that the plugins tested are inherently flawed, buggy or broken. I am sure that all of them work under the right circumstances and for the right workflows.

CakePHP模式外壳

CakePHP Schema Shell


  • 有我喜欢的简单概念。

  • Has the simple concept I like. The Schema is linked to the code and the SCM used to manage its revisions.

对一个点有效果。这一点是:

Works great to a point. That point being:

似乎不适合自动部署。也就是说update命令只能修改表,不能处理新表或删除表。这些都是由自己的shell命令处理,使Cap-style部署复杂。当脚本尝试改变不存在的表时,使用新表运行更新将产生错误。我注意到,如果这是目的或我有一个问题。 (尚未向Google群组发出回应但尚未回覆)

Does not appear suitable to automated deployment. I.e. The update command can only modify tables, not handle new or removed tables. Those are handled by their own shell commands making Cap-style deployment complicated. Also running updates with a new table will produce errors when the script tries to "Alter" the non-existing table. I am note sure if this is intended or a problem I am having. (Have asked on the google group with no reply yet)

CakeDC迁移


  • 听起来像他们采用了Schema Shell并且固定它。

YAML,joelmoss和juan的迁移

YAML, joelmoss and juan's migrations


  • 这些都共享版本化文件的rails概念和它们之间的upping我喜欢这个少,因为我不能看到我的项目的情况下,模式迁移将更新或回滚,而不做同样的源代码。我也可以生活没有迁移现有数据在迁移脚本的能力,因为我预见,作为一个非常罕见的事情我。

  • These all share the rails concept of versioned files and "upping" and "downing" between them. I like this less since I can not see a situation for my projects when the a schema migration would be updated or rolled back without doing the same to the source code. I can also live without the ability to migrate existing data in a migration script since I foresee that as a very rare occurrence for me.

这些都期望我不通过除迁移脚本之外的任何其他方式触摸数据库。我不能打开我最喜欢的MySql-GUI和玩,直到我很高兴,然后通过这些脚本生成一个差异。 (至少我没有找到记录的方式,在我的简短测试)。我必须手动写入YAML或PHP文件中的更改。由于我开始在一个现有的项目大约30表,我不喜欢手动重写该架构的想法。但是这些插件中的一些没有创建一个很好的起点文件与所有我的表。这也可能是由于我的简短测试和/或无法找到这样的功能的文档。我没有深入这些大部分的源代码。

These all expect me to not touch the database via any other means than migration scripts. I can not open my favorite MySql-GUI and play around until I am happy and then generate a "diff" via these scripts. (At least I have not found documented ways of doing it during my brief tests.) I have to manually write the changes in YAML or php files. Since I am starting out on an existing project with around 30 tables I do not relish the idea of re-writing that schema manually. But a few of these plugins did not create a good starting point-file with all my tables. This was also probably due to my brief testing and/or inability to find documentation for such a feature. I did not dive into the source code for most of these.

我的下一步看起来更新我的项目CakePHP 1.3并给最后一个插件一试。但我不知道什么时候我会有时间。 (即没有人呼吸)

My next step looks to be updating my project to CakePHP 1.3 and give the last plugin a try. But I do not know when I will have time for it. (i.e. don't anyone hold their breath)

如果你认为我误解了这些插件是如何工作的,可以提供命中,如何使他们为我工作。我很乐意回复评论。

If you think I have misunderstood how any of these plugins work and can offer hits as to how to make them work for me. I'd be happy for a reply of a comment.

这篇关于好的DB迁移为CakePHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆