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

本文是小编为大家收集整理的关于CakePHP的良好DB迁移?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我一直在尝试一些cakephp的迁移脚本,但我以某种形式或其他形式遇到了所有问题.

请给我建议您使用现场和了解作品的蛋糕的迁移选项.

我想要以下"功能":

  • 支持CakePHP 1.2(例如,Cakedcs迁移仅在1.3稳定并且我的应用程序迁移到新代码库时才是一种选择)
  • 支持(或至少不停止)具有不同数据库配置的模型.
  • App/Models的子文件夹中的支持模型
  • 插件中的支持模型
  • 不符合蛋糕约定的支撑桌(我有一些没有单个主要钥匙字段并且需要保留的特殊表)
  • )
  • 通过Capistrano和git进行自动部署的效果很好.

我不需要Rails Style版本的文件,将Git版本的模式文件与现有模式进行了比较.也就是说:我喜欢蛋糕中的schemashell,除了它与上面的大多数要求不兼容.

我已经看过并测试了:

推荐答案

快速尝试Juan的插件以及其他所有提到的内容之后,我将尝试使用我的发现更新此"主题",除了CakeDC的插件,因为我没有更新有关CakePHP的相关应用程序1.3并且该迁移插件需要1.3

我必须注意,关于失败和插件对我不起作用的评论应主要被理解为"不适合我的需求"或"尝试时我犯的错误".在某种程度上,有些人可能会阅读此类评论,例如对文档进行修订的请求.我并不意味着经过的插件本质上是有缺陷,越野车或破坏的.我相信所有这些都在正确的情况下和正确的工作流程中工作.

cakephp架构外壳

  • 有一个简单的概念.该模式链接到代码和用于管理其修订的SCM.

  • 效果很好.这一点是:

  • 似乎不适合自动部署. IE.更新命令只能修改表,而不能处理新的或删除的表.这些由自己的外壳命令处理,使盖式部署变得复杂.此外,使用新表运行更新将在脚本尝试"更改"不存在的表时产生错误.我注意确定这是打算的还是我遇到的问题. (尚未在Google Group上询问)

cakedc迁移

  • 听起来像是他们拿走了模式外壳并"修复"了.文档解释了一个程序稍微复杂得多(至少要解释),但它可能会像我想要的那样起作用.

yaml,乔尔莫斯和胡安的迁移

我的下一步看起来是将我的项目更新为cakephp 1.3,并尝试一下最后一个插件.但是我不知道什么时候有时间去做. (即,没有人屏住呼吸)

如果您认为我误解了这些插件中的任何一个,并且可以为如何使它们工作.我很高兴回复评论.

其他推荐答案

如果您喜欢铁轨迁移,请使用Rails迁移...看看这个宝石 https ://github.com/thuss/standalone migrations .我在日常工作中使用这颗宝石和cakephp.

其他推荐答案

我有一个插件,可以将其添加到cakephp 1.2,您可以在 http:http://github .com/jrbasso/迁移

它使用蛋糕风格制作万物.不使用yaml,使用对象定义表.您可以从蛋糕中进口型号而没有问题...

本文地址:https://www.itbaoku.cn/post/597489.html

问题描述

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.

其他推荐答案

If you like Rails migrations, use Rails Migrations... take a look at this gem https://github.com/thuss/standalone-migrations . I use this gem with cakephp in my daily work.

其他推荐答案

I have a plugin that make it to CakePHP 1.2, you can see in http://github.com/jrbasso/migrations

It use cake style to make all things. Not uses yaml, uses objects to define tables. You can import models from Cake without problems...