Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Is there any Ruby script for converting a PostgreSQL database to a MySQL database? I have searched many sites to no avail.

share|improve this question
    
Are you using Ruby on Rails ? –  khmarbaise Apr 21 '10 at 9:23
    
yes am using ruby on rails only –  sangeethkumar n Apr 21 '10 at 11:12

1 Answer 1

To be honest these migrations can be tricky. I don't know that there are any good tools to do it. Also note that this can be a major pain, and you end up giving up on a lot of nice features that PostgreSQL has for agile development (like transactional DDL). This being said, here's the way to go about it:

  1. Rebuild your schema on MySQL. Do not try to convert schema files per se. Use your existing approaches to generate a new schema using MySQL's syntax.

  2. Write a script which pulls data from PostgreSQL and inserts it one row at a time into MySQL. MySQL has some thread locking problems that interfere with bulk loads, updating indexes, etc,. where multiple rows are inserted per statement. For deciding the table order, what I have usually started with is the order the tables are listed in pg_dump, though in Rails you may be able to use your model definition instead.

  3. Review your indexing strategies to make sure they are still applicable.

On the whole these dbs are very different. I would not expect that the migration will be easy.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.