具有旧数据库架构的 DataMapper。通过序列表的主键
更新:我最后为 DataMapper 编写了一个 Sequence 属性类型。自行承担风险;)https://gist.github.com/959059
我们将已投入生产的大型 PHP Web 应用程序迁移到 Ruby on Rails。我们的架构与 ActiveRecord 的默认设置相距甚远,而且它太大而无法简单地迁移架构,因此我放弃了 ActiveRecord 并开始使用 DataMapper,这使我们能够更轻松地隐藏架构差异。这对于我所做的一些只读测试效果很好。
现在,与我们的架构最大的不兼容性之一是我们使用 ADODB 并在插入之前使用 sequences
表(这是常见模式)而不是 auto_increment 生成主键。
有没有办法告诉DataMapper以同样的方式生成ID?我在文档中没有看到提及它。
我们无法真正将表切换为使用 auto_increment,因为应用程序的大小意味着我们实际上正在运行具有一些代理和会话共享的混合 Rails/PHP 设置,以便我们可以逐步迁移,因此 PHP 应用程序需要继续工作按原样使用架构(或仅进行微小更改)。
UPDATE: I wrote a Sequence property type for DataMapper in the end. Take and use at your own risk ;) https://gist.github.com/959059
We're moving a large, already in production PHP web application to Ruby on Rails. Our schema is far from compatible with ActiveRecord's defaults, and it's too large to simply migrate the schema, so I've ditched ActiveRecord and started using DataMapper, which allows us to hide the schema differences more easily. This is working well with some read-only tests I've done.
Now, one of the biggest incompatibilities with our schema is that we use ADODB and generate primary keys prior to the insert, using a sequences
table (this is a common pattern), instead of with auto_increment.
Is there a way to tell DataMapper to generate IDs in the same way? I don't see mention of it in the docs.
We can't really switch the tables to use auto_increment because the size of the application means we're actually running a hybrid Rails/PHP setup with some proxying and session sharing so we can progressively migrate across, therefore the PHP application needs to keep working with the schema as-is (or with only minor changes).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我真的应该发布该编辑作为答案:
我最后为 DataMapper 编写了一个 Sequence 属性类型。自行承担风险;)https://gist.github.com/959059
I should really have posted that edit as an answer:
I wrote a Sequence property type for DataMapper in the end. Take and use at your own risk ;) https://gist.github.com/959059