dpfad62426
2014-08-20 14:58
浏览 22

将MySQL数据从旧版PHP应用程序迁移到Rails应用程序[关闭]

I am currently rebuilding a legacy application in Rails. The legacy application is based on PHP and uses a MySQL database.

The main challenge thus far is migrating the data across and conforming to a structure that is suitable for Rails.

The legacy PHP app has many tables with most having an identical column structure, the only exception being a couple of tables with additional columns. The reason for the separation is the data is being inserted by many different scripts, so just for troubleshooting/safety they are all split up.

What is the best way to transition this data across to Ruby on Rails?

图片转代码服务由CSDN问答提供 功能建议

我目前正在Rails中重建遗留应用程序。 遗留应用程序基于PHP并使用MySQL数据库。

到目前为止,主要的挑战是迁移数据并符合适合Rails的结构。

遗留PHP应用程序有许多表,其中大多数具有相同的列结构,唯一的例外是几个带有其他列的表。 分离的原因是数据被许多不同的脚本插入,因此只是为了排除故障/安全性,它们都被分开了。

将这些数据转换为最佳方法的最佳方法是什么 Ruby on Rails?

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongxiz5342 2014-08-20 15:09
    已采纳

    If I were you, I would replicate / use the exact db as is, switch to Rails front-end and start verifying. Assuming you are using ActiveRecord, you can easily overcome the issues of default primary key (id), foreign key by using something like this:

    class ModelName < ActiveRecord::Base
      self.table_name = 'your old table / replicated table'
      self.primary_key = 'your old primary key'
      ...
    end
    

    Associations can be specified as below

    ...
      belongs_to :something, :foreign_key => 'old foreign key', :primary_key => 'pri_key'
    ...
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题