dongyi8383 2011-02-15 13:46
浏览 33
已采纳

在为多应用程序Kohana环境开发厚模块的同时保持数据库最新

I'm currently planning out on how to maintain several thin projects which shares a bunch of thick modules in Kohana.

The plan is to have some modules, like "blog", "forum" etc. And then a bunch of separate projects which shares some modules.

As you can image, most of the modules will have a database dependency.

So, when a module is deployed to a project, the back-end database must be updated accordingly. (Also note that when an update of a module is deployed, the database might have to be altered.)

A good solution to this is Migrations, I've seen some implementations of them for Kohana, but almost all of them are application-specific and can not be used with mere modules. (Please correct me if I'm wrong)

What I really want to know is: Is there a good way to automatically update the back-end database on deploy with Kohana?

  • 写回答

1条回答 默认 最新

  • dragon88112 2011-02-15 14:35
    关注

    First thing you need to address is what migrations module you are going to use. There's a nice one based off a module called Minion, see the tasks-migrations repository. You can specify migration locations which are directories inside your migrations directory.

    classes/migrations/[location]
    

    So passing the argument --location=module would only execute migrations inside that directory, that's how you'd separate and run per module migrations.

    If you leave off --location then all migrations are run (need to double check this)

    The neat thing about minion is each location can use a different database group if you specify it, allows for a lot of flexibilty.

    The next thing you have to deal with is deployment. I personally do this with Capistrano, so on a new deployment I'd run the minion command to bring up the database to the latest version.

    Take a look at these two code samples to see how you might integrate running migrations with Capistrano.

    1. http://pastie.org/459506
    2. https://gist.github.com/410363
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况