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

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

问题描述

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



请在迁移选项



我想要以下功能:




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

  • 支持

  • 在插件的支持模型

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




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



我已经看过并测试过:




解决方案

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



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

CakePHP模式外壳




  • 有我喜欢的简单概念。


  • 对某个点有效。这一点是:


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




CakeDC迁移




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



YAML,joelmoss和juan的迁移




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


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




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



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


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

Please advice me on a migration option for Cake that you use live and know works.

I'd like the following "features":

  • 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.

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.

I have looked at and tested:

解决方案

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 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:

  • 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 migrations

  • Sound like they took the Schema Shell and "fixed" it. The docs explain a procedure slightly more complicated (to explain at least) but it might work as I want it to.

YAML, joelmoss and juan's migrations

  • 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.

  • 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.

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天全站免登陆