Good DB Migrations for CakePHP?

前端 未结 5 1948
暗喜
暗喜 2021-01-31 19:48

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 t

相关标签:
5条回答
  • 2021-01-31 20:27

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

    0 讨论(0)
  • 2021-01-31 20:29

    Use the 3.x Migrations plugin here.

    All the issues the other older tools have are fixed by design. And it is under heavy development and gets more features and fixes every week.

    You can also easily use the new tool for existing 1.x and 2.x apps. I just released a post on how to use 3.x Migrations in 2.x apps by the way.

    0 讨论(0)
  • 2021-01-31 20:40

    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.

    0 讨论(0)
  • 2021-01-31 20:41

    I've used the CakeDC migrations plugin for 1.3.x and 2.x in production environments and have been pleased. There are some bugs related to creating migrations in the 1.3.x version, but they're easy to fix.

    0 讨论(0)
  • 2021-01-31 20:42

    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.

    0 讨论(0)
提交回复
热议问题