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

报告相同问题?

悬赏问题

  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)
  • ¥15 52810 尾椎c三个a 写蓝牙地址