如何构建“迁移”或 FuelPHP 中模块的类似功能

发布于 2024-12-21 13:39:20 字数 682 浏览 2 评论 0原文

FulePHP 是一个 HMVC 框架,允许“模块”拥有自己的 MVC 结构。该框架还提供了一个名为“迁移”的方便工具,可以解决数据库和数据迁移问题。以优雅的方式解决代码版本冲突(在开发过程中)。

然而,迁移工具是应用程序方面的。包DB Schemae和的管理不支持夹具。

我想出了这些替代解决方案:

  1. 构建并测试每个模块及其依赖项作为 FuelPHP 项目,以便可以专门使用“迁移”。需要大量配置,并具有严格的环境(开发/生产)分支策略。
  2. 更新或安装模块后,扫描“APPPATH/modules/[mod_name]/migrations”中的文件并将其链接到“migrations”。
  3. 传统方式:维护数据库模式和数据库的 sql 文件。手动固定,如果在运行时找不到表则加载。

将解决方案 1 和 2 结合起来似乎是合理的,但需要大量的工作。是否有一些优雅的方法可以做到这一点,或者将迁移支持移植到模块?

提前致谢。

** 编辑,“模块”应该是我正在寻找的地方,而不是“包”

简而言之,我希望我的模块目录看起来像

    • 控制器
    • 型号
    • 查看
  • 配置
  • 迁移
  • lang
  • 视图

FulePHP is a HMVC framework that allows 'modules' to have their own MVC structure. The framework also provides a handy tool called 'migration', that resolves database & code version conflicts (during development) in an elegant way.

However, the migration tool is app-wise. Management of package DB Schemae & Fixtures is not supported.

I came up with these alternative solutions :

  1. Build and test each modules with it's dependency as a FuelPHP project, so that 'migrations' can be used exclusively. Requires a whole lot of configurations, with a strict and environment (dev/production) branch policy.
  2. Scan and link files in 'APPPATH/modules/[mod_name]/migrations' to 'migrations' after updating or installing a modules.
  3. The legacy way: Maintain sql files for DB schema & fixture by hand, loaded if tables were not found at runtime.

Combining solution 1 and 2 seems reasonable, but would take a great amount of work. Is there some elegant way to do so, or to port migration support to modules?

Thanks in advance.

** edited, 'modules' should be where I'm looking for, not 'packages'

In short, I'd like to have my module directory look like:

  • classes
    • controller
    • model
    • view
  • config
  • migrations
  • lang
  • views

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羅雙樹 2024-12-28 13:39:20

已经支持包中的迁移。

Migrations in packages are already supported.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文