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
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历