문제

I'm migrating a Rails 2 application to Rails 3. The thing is the application I'm migrating has some legacy data from the Rails 2 version. I need to import that legacy data into the Rails 3 version, but I have changed the tablenames from version 2 to version 3.

I don't have a clue on how to do this and all the research i've done it seems to be outdated.

Any idea?

EDIT

I found Pentaho, a program that helps you migrate data from one database to another. It's very flexible, you can even configure the fields you want to fill if you need to save some legacy attributes in your new database. I greatly recommend it.

도움이 되었습니까?

해결책

If the database structure is the same in both rails2 and rails3 apps you can consider backing up the old database and then import data to the new database. For example MySQL has mysqldump utility that you can use to dump the database. Then restore the new database from the new dump file.

if you need to do that via rails3 app, then your best bet would be to add new database config section in config/database.yml for the old db and then using a using activerecord import the data to the new database.(probably by a rake task).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top