<p>I have two databases with the same structure. The tables have an integer as a primary key as used in Rails.</p>

<p>If I have a patients table, I will have one patient using primary key 123 in one database and another patient using the same primary key in the other database.</p>

<p>What would you suggest for merging the data from both databases?</p>

Set both your databases up with entries in config/database.yml, then generate a new migration.
Use ActiveRecord::Base.establish_connection to switch between the two databases in the migration like this:
```
```
def self.up
  ActiveRecord::Base.establish_connection :development
  patients = Patient.find(:all)
  ActiveRecord::Base.establish_connection :production
  patients.each { |patient| Patient.create patient.attributes.except("id") }
end
```
```
YMMV depending on the number of records and the associations between models.